How can i give my code the ability to include "+" and "-" sign in exam grades . | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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

31st Jan 2022, 6:14 AM
Chioma Chieke
4 Respostas
+ 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.
31st Jan 2022, 6:33 AM
NotHuman
NotHuman - avatar
+ 2
Simply set the value to "A-"!
31st Jan 2022, 7:17 AM
Abhiyantā
Abhiyantā - avatar
+ 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.
31st Jan 2022, 7:43 AM
Ipang
+ 2
thanks. I understand now
1st Feb 2022, 2:42 AM
Chioma Chieke