codescracker


python

Python Program to Calculate Average and Percentage Marks



« Previous Program Next Program »


Calculate Average and Percentage Marks in Python

To calculate average and percentage marks in python, you have to ask from user to enter marks obtained in 5 subjects to calculate and print the average and the percentage marks as shown in the program given below.

Python Programming Code to Calculate Average and Percentage Marks

Following python program ask from user to enter marks obtained in 5 subjects to find the average and percentage marks:

# Python Program - Calculate Average and Percentage Marks
		
while True:
	print("Enter 'x' for exit.")
	print("Enter marks obtained in 5 subjects: ")
	m1 = input()
	m2 = input()
	m3 = input()
	m4 = input()
	m5 = input()
	if m1 == 'x':
		break
	else:
		mark1 = int(m1)
		mark2 = int(m2)
		mark3 = int(m3)
		mark4 = int(m4)
		mark5 = int(m5)
		sum = mark1 + mark2 + mark3 + mark4 + mark5
		average = sum/5
		percentage = (sum/500)*100
		print("Average Marks = ", average)
		print("Percentage Marks = ", percentage, "%\n")

Here is the sample run of the above Python program shows how to calculate and print average marks and percentage marks of students:

python calculate average and percentage marks

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 »




Tools
Calculator

Quick Links
Signup - Login - Give Online Test