Basic Programs

If Else Programs

While loop Programs

For loop Programs

List Programs


Python Program to Calculate the Grade of a Student


In this example shows, how to calculate the grade of a student based on 5 subject mark .Using if,elif,else.

Steps
  1. Get the 5 subject marks as an input from user.
  2. Calculate the average for 5 subject marks.
  3. Determine the grade based on average.
Here the Example , Find the grade of student for given mark using if ,elif ,else statement.
Example.py
subject1 = int(input('Enter the subject1 Mark:'))
subject2 = int(input('Enter the subject2 Mark:'))
subject3 = int(input('Enter the subject3 Mark:'))
subject4 = int(input('Enter the subject4 Mark:'))
subject5 = int(input('Enter the subject5 Mark:'))

tot = subject1+subject2+subject3+subject4+subject5
avg=tot/5

if avg >= 90:
    grade = 'A'
elif avg >= 80:
    grade = 'B'
elif avg >= 70:
    grade = 'C'
elif avg >= 60:
    grade = 'D'
else:
    grade = 'F'

print("Average:",avg)
print("The student Grade is ",grade)

Output

Enter the subject1 Mark:96
Enter the subject2 Mark:85
Enter the subject3 Mark:36
Enter the subject4 Mark:57
Enter the subject5 Mark:68
Average: 68.4
The student Grade is  D

Prev Next