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.
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:
You may also like to learn or practice the same program in other popular programming languages: