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
- Get the 5 subject marks as an input from user.
- Calculate the average for 5 subject marks.
- 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