Python Program to Calculate Grade of Student

« Previous Program Next Program »

Calculate Grade of Student in Python

To calculate grade of students in python, you have to ask from user to enter marks obtained in 5 subjects and calculate the sum of all the marks and then calculate the average marks to find the grade according to the average marks obtained by student as shown in the program given below.

Python Programming Code to Calculate Grade of Student

Following python program ask from user to enter marks obtained in 5 subjects to calculate the grade of student:

# Python Program - Calculate Grade of Student
while True:
	print("Enter 'x' for exit.")
	print("Enter marks obtained in 5 subjects: ")
	mark1 = int(input())
	mark2 = int(input())
	mark3 = int(input())
	mark4 = int(input())
	mark5 = int(input())
	if mark1 == 'x':
		sum = mark1 + mark2 + mark3 + mark4 + mark5
		average = sum/5
		if(average>=91 and average<=100):
			print("Your Grade is A+")
		elif(average>=81 and average<=90):
			print("Your Grade is A")
		elif(average>=71 and average<=80):
			print("Your Grade is B+")
		elif(average>=61 and average<=70):
			print("Your Grade is B")
		elif(average>=51 and average<=60):
			print("Your Grade is C+")
		elif(average>=41 and average<=50):
			print("Your Grade is C")
		elif(average>=0 and average<=40):
			print("Your Grade is F")
			print("Strange Grade..!!")

Here are some sample runs of the above python program to demonstrate how to calculate the grade of student. This is the first snapshot:

python calculate grade of student

This is the second snapshot:

calculate student grade in python

Here is the third snapshot:

find student grade in python

Same Program in Other Languages

You may also like to learn or practice the same program in other popular programming languages:

« Previous Program Next Program »

Latest 5 Posts by CodesCracker


Quick Links
Signup - Login - Give Online Test