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 print("Enter 'x' for exit."); print("Enter marks obtained in 5 subjects: "); m1 = input(); if m1 == 'x': exit(); else: m2 = input(); m3 = input(); m4 = input(); m5 = input(); 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,"%");
Here is the sample run of the above Python program shows how to calculate and print average marks and percentage marks of students:
Above screenshot shows the initial output, now you have to enter your marks obtained in 5 subjects one by one and then press enter key to see the average and percentage marks of all the given marks of 5 subjects as shown in below sample screenshot (output):
Here is the same program with run directly on python shell:
Program Video with Compile and Run
You may also like to learn or practice the same program in other popular programming languages: