Python: How to calculate total, average and percentage of marks of five subjects

Program 10. Write a python program to input marks of five subjects of a student and calculate total, average and percentage of all subjects. How to calculate total, average and percentage of marks of five subjects in python programming.

Logic to find total, average and percentage in python program.

For Example
Input
Enter marks of five subjects: 95 76 85 90 89
Output
Total = 435
Average = 87
Percentage = 87.00

Logic to find total, average and percentage
Step by step descriptive logic to find total, average and percentage is –
1. Read marks of five subjects in some variables say S1, S2, S3, S4 and S5.
2. Apply the formula for finding sum i.e. total = S1 + S2 + S3 + S4 + S5.
3. Apply the formula to find average using above total i.e. average = total / 5.
4. Apply the formula for finding percentage i.e. percentage = (average / 500) * 100.
5. Finally print values of all resultant variables total, average and percentage.

#Let us code for Solution:
print(“\n\t\t\t https://learnpythonforcbse.wordpress.com/”)

#Read marks of all five subjects
print(“Enter marks of five subjects: “)
S1=float(input())
S2=float(input())
S3=float(input())
S4=float(input())
S5=float(input())

#Calculate total, average and percentage one by one
total = S1 + S2 + S3 + S4 + S5;
average = total/5.0;
percentage = (total / 500.0) * 100;

#Print the result
print(“Total marks = “, total)
print(“Average marks = “, average)
print(“Percentage = “, percentage)
print(“\n\t\t\t https://learnpythonforcbse.wordpress.com/”)

OUTPUT:

prog10.png