0
How can i give my code the ability to include "+" and "-" sign in exam grades .
Example 97-100 should be A+ 96-93 should be A- . 90-92 is just "A" . 87-89 is B+ and so on (Python) grade=float(input('Please input your Grade Percentage: ')) if grade >=90: letter='A' elif grade >=80: letter='B' elif grade >= 70: letter='C' elif grade >= 60: letter='D' elif grade < 60: letter='F' print(f'Your Grade is {grade}={letter}') if grade >= 70: print('Congratualtion you passed the Course') else: print('Am Sorry you didint pass the Course\nYou need to try harder next time') so I want it to print either plus or minus sign immediately after the letter. like A+ B-, but I want it to detect when to print it
4 Réponses
+ 2
Instead of just giving one condition you can give two conditions using the "or" keyword. And then you can specify it to A- or whatever output you want.
+ 2
Simply set the value to "A-"!
+ 2
You can nest another if...elif...else block inside, like this for example ...
if grade >= 90:
if grade >= 97:
letter = 'A+'
elif grade >= 93:
letter = 'A-'
else:
letter = 'A'
You can use the same approach for other grading blocks, with adjustments on the ranges.
+ 2
thanks. I understand now