Input mark and print grade in Python
if elif - Question 10
In this question, we will see how to input mark obtained in English subject in an examination and print the grades accordingly in Python programming using the if elif statement. To know more about if elif statement click on the if elif statement lesson.
Q10) Write a program in Python to input mark obtained in English subject in an examination and print the grades accordingly.
Marks in English | Grade |
90 or above | A |
70 to 89 | B |
50 to 69 | C |
40 to 49 | D |
Below 40 | F |
Program
e=int(input('Enter marks obtained in English subject '))
if e>=90:
print('Grade = A')
elif e>=70 and e<=89:
print('Grade = B')
elif e>=50 and e<=69:
print('Grade = C')
elif e>=40 and e<=49:
print('Grade = D')
else:
print('Grade = F')
Output
Enter marks obtained in English subject 68 Grade = C