Python program that accepts marks in 5 subjects and outputs average marks; In this tutorial, i am going to show you how to find or calculate total marks, average and percentage of five subjects in python.
Python program that accepts marks in 5 subjects and outputs average marks
Use the following steps to write program to accept marks of 5 subject and display total marks and percentage of marks:
- Get input five different marks for five subjects from user in program.
- Sum all subjects marks using arithmetic operator and store it into variable.
- Find average of 5 subject marks using this formula average = total / 5 and store it into variable.
- Calculate percentage using this formula: percentage = (total / 500) * 100.
- Print total marks and percentage of 5 subjects.
# Python Program to find Total, Average, and Percentage of Five Subjects english = float(input("Please enter English Marks: ")) math = float(input("Please enter Math score: ")) computers = float(input("Please enter Computer Marks: ")) physics = float(input("Please enter Physics Marks: ")) chemistry = float(input("Please enter Chemistry Marks: ")) total = english + math + computers + physics + chemistry average = total / 5 percentage = (total / 500) * 100 print("\nTotal Marks = %.2f" %total) print("Average Marks = %.2f" %average) print("Marks Percentage = %.2f" %percentage)
After executing the program to calculate total marks and percentage of three subjects in python, the output will be:
Please enter English Marks: 80 Please enter Math score: 90 Please enter Computer Marks: 78 Please enter Physics Marks: 89 Please enter Chemistry Marks: 87 Total Marks = 424.00 Average Marks = 84.80 Marks Percentage = 84.80
Note that, you can also modify the above program to calculate total marks and percentage of three subjects in python
Recommended Python Tutorials
Recommended:-Python Program to Check Leap Year
Recommended:-Python Program To Print Number Pattern
Recommended:-Python Program to Print Star Pattern
Recommended:-Python Program Calculate Sum of n Numbers
Recommended:-Python Program to Reverse Numbers
Recommended:-Python Program to Find Largest of n Numbers
Recommended:-Python Program to Find Power of Number
Recommended:-Python Program to Print Prime Number From 1 to N
Recommended:-Python Program to Find Square Root of Number
Recommended:-Python Program to Find Cube of Number
Recommended:-Python Palindrome Program
Recommended:-Python Program to Count Set Bits in a Number
Recommended:-Python Program for BMI Calculation
Recommended:-Python Program to Find Out Absolute Value
Recommended:-Python Random Number Generator Code
Recommended:-Python program for Zip, Zap and Zoom game
Recommended:-Python Program to Swap Two Numbers
Recommended:-Python Program to Find n-th term of Fibonacci Series
Recommended:-Python Program For Calculator
Recommended:-Python Program to Find Strong Number
Recommended:-Python Program to Convert cm to Feet and Inches
Recommended:-How to Reverse a List in Python
Recommended:-Python Program to Convert Celsius to Fahrenheit
Recommended:-Python Program to Find Standard Deviation