0

I need help figuring out what I am doing wrong on python 3.

I am a beginner in python 3, and I was trying to make a code which changes a percentage score into a letter grade. I ran into a problem where if I type number above 95 it shows me all my if statement in a row even though I only want it to show me the first one. Here is my code. print(" Welcome to the letter grade finder") print("just type in you percentage and I will tell you letter grade") #Type Grade here: grade=100 #Now click run if grade>=95 and >=100: print("\n \n \n You got an A+, Excellent, you have exceeded the expectations!!!") elif grade >= 87: print("\n \n \n You got an A, Great job, you have exceeded the expectations!!!") if grade>=80: print("\n \n \n You got an A-, You are doing good, you have exceeded the expectations!!!") elif grade >= 77: print("\n \n \n You got an B+, You worked hard, You are slightly above the expectations :)") if grade >= 74: print("\n \n \n You got an B, Perfect, You are meeting the expectations :) ") elif grade >= 70: print("\n \n \n You got an B-, So close, You are slightly below the expectations :) ") if grade >= 67: print("\n \n \n You got an C+, Try harder next time, You are below expectations :o ") elif grade >= 64: print("\n \n \n You got an c, Come on, do better, you are below expectations :o ") if grade >= 60: print("\n \n \n You got an C-, You are not trying hard enough , you are below expectations :o") Can someone please help me?

30th Nov 2020, 7:46 PM
Monisha
4 Réponses
+ 2
Use elif for all Put grade<=100 And last grade<=60: print("Welcome to the letter grade finder") print("just type in you percentage and I will tell you letter grade") #Type Grade: grade=int(input()) #Now click run if grade>=95 and grade<=100: print("\n \n \n You got an A+, Excellent, you have exceeded the expectations!!") elif grade >= 87: print("\n\n\nYou got an A, Great job, you have exceeded the expectations!!") elif grade>=80: print("\n\n\nYou got an A-, You are doing good, you have exceeded the expectations!!") elif grade >= 77: print("\n\n\nYou got an B+, You worked hard, You are slightly above the expectations :)") elif grade >= 74: print("\n\nYou got an B, Perfect, You are meeting the expectations :) ") elif grade >= 70: print("\n\n\nYou got an B-, So close, You are slightly below the expectations :)") #i removed case C+, C, ..you can add here again.. elif grade <= 60: print("\n\n\nYou got an C-, not trying hard enough , you are below expectations :")
30th Nov 2020, 8:29 PM
Jayakrishna 🇮🇳
0
#maybe try this? if grade>=95 and grade<=100:
30th Nov 2020, 7:50 PM
Steven M
Steven M - avatar
0
Replace all but the first "if" with "elif".( and as Steven M mentioned). Edit...I wouldn't bother with grade <= 100 as I don' think you can get over 100% as a grade...but that's up to you
30th Nov 2020, 8:23 PM
rodwynnejones
rodwynnejones - avatar
0
Thank you so much, it works now!!!
7th Dec 2020, 7:01 PM
Monisha