# Python Program to Calculate Total Marks Percentage and Grade of a Student

In this article, you will learn how to find the **Total**, **Average**, **Percentage**, and **Grade** of a student in the Python language.

### Example

**Enter the marks of five subjects::
98
92
87
82
75**

**The Total marks is: 434.0 / 500.00**

**The Average marks is: 86.8**

**The Percentage is: 86.8 %**

**The Grade is: B**

You should have the knowledge of the following topics in python programming to understand this program:

- Objective Python
- Python Functions
- Python
**If**statement - Python
**input()**function - Python
**print()**function

### Standard Formula

**Total = marks1 + marks2 + marks3 + marks4 + marks5**

**Average = Total / 5.0**

**Percentage = (Total / 500.0) x 100**

Where `marks1`

, `marks2`

, `marks3`

, `marks4`

, and `marks5`

are the marks of five subjects.

## Program to find average and grade for given marks in python

```
# Python Program to Calculate Total Marks Percentage and Grade of a Student
print("Enter the marks of five subjects::")
subject_1 = float (input ())
subject_2 = float (input ())
subject_3 = float (input ())
subject_4 = float (input ())
subject_5 = float (input ())
total, average, percentage, grade = None, None, None, None
# It will calculate the Total, Average and Percentage
total = subject_1 + subject_2 + subject_3 + subject_4 + subject_5
average = total / 5.0
percentage = (total / 500.0) * 100
if average >= 90:
grade = 'A'
elif average >= 80 and average < 90:
grade = 'B'
elif average >= 70 and average < 80:
grade = 'C'
elif average >= 60 and average < 70:
grade = 'D'
else:
grade = 'E'
# It will produce the final output
print ("\nThe Total marks is: \t", total, "/ 500.00")
print ("\nThe Average marks is: \t", average)
print ("\nThe Percentage is: \t", percentage, "%")
print ("\nThe Grade is: \t", grade)
```

### Output

`Enter the marks of five subjects::`

98

92

87

82

75

`The Total marks is: 434.0 / 500.00`

`The Average marks is: 86.8`

`The Percentage is: 86.8 %`

`The Grade is: B`

### Explanation

` Average:` we take the marks of five subjects as input after that the sum of these marks divided by

**5**then It will return the average value of the marks.

` Percentage:` we made a division of the sum of user's marks by

**500**then multiplied by

**100**then It will return the percentage value of the marks.

` Grade:` we compared the value of the Average marks with these range of marks to find the Grade of student like:

If `Average marks >= 90`

then It's Grade is **'A'**

If `Average marks >= 80 and < 90`

then It's Grade is **'B'**

If `Average marks >= 70 and < 80`

then It's Grade is **'C'**

If `Average marks >= 60 and < 70`

then It's Grade is **'D'**

If `Average marks < 60`

then It's Grade is **'E'**

## Program to find average and grade for given marks in python Using Function

```
# Program to find average and grade for given marks in python Using Function
# Custom function to Display Percentage & Grade
def CalcPercentGrade (S_1, S_2, S_3, S_4, S_5):
# It will calculate the Total, Average and Percentage
total = S_1 + S_2 + S_3 + S_4 + S_5
average = total / 5.0
percentage = (total / 500.0) * 100
if average >= 90:
grade = 'A'
elif average >= 80 and average < 90:
grade = 'B'
elif average >= 70 and average < 80:
grade = 'C'
elif average >= 60 and average < 70:
grade = 'D'
else:
grade = 'E'
# It will produce the final output
print ("\nThe Total marks is: \t", total, "/ 500.00")
print ("\nThe Average marks is: \t", average)
print ("\nThe Percentage is: \t", percentage, "%")
print ("\nThe Grade is: \t", grade)
# Driver function to Run this Program
print("Enter the marks of five subjects::")
subject_1 = float (input ())
subject_2 = float (input ())
subject_3 = float (input ())
subject_4 = float (input ())
subject_5 = float (input ())
total, average, percentage, grade = None, None, None, None
# It will produce the final output
CalcPercentGrade (subject_1, subject_2, subject_3, subject_4, subject_5)
```

### Output

`Enter the marks of five subjects::`

97

96

92

88

85

`The Total marks is: 458.0 / 500.00`

`The Average marks is: 91.6`

`The Percentage is: 91.60000000000001 %`

`The Grade is: A`

Visit this page to learn how to __Find the Area of Rectangle in Python__

## Python Program to Calculate Total Marks Percentage and Grade of a Student Using Class

```
# Python Program to Calculate Total Marks Percentage and Grade of a Student Using Class
class StudentData:
def __init__(self):
self.Total = 0.00
self.Average = 0.00
self.Percentage = 0.00
self.Marks = []
self.MaxMarks = 0.00
def main(self):
print("Enter the marks of five subjects::")
for i in range(5):
self.Marks.append( float (input ()))
def CalcMaxMarks (self):
return len (self.Marks) * 100
def CalcTotal (self):
self.Total = 0
for i in self.Marks:
self.Total += i
return self.Total
def CalcAvg (self):
self.Average = self.Total / len (self.Marks)
return self.Average
def CalcPercentage (self):
return (self.Total * 100) / (len (self.Marks) * 100)
def CalcGrade (self):
Grade = None
if self.Average >= 90:
Grade = 'A'
elif self.Average >= 80 and self.Average < 90:
Grade = 'B'
elif self.Average >= 70 and self.Average < 80:
Grade = 'C'
elif self.Average >= 60 and self.Average < 70:
Grade = 'D'
else:
Grade = 'E'
return Grade
def CalcResult (self):
c = 0
for i in self.Marks:
if i >= 40:
c += 1
if c == len (self.Marks):
return 'Passed'
else:
return 'Failed'
# It will create instance of the StudentData class
StudentData = StudentData()
StudentData.main()
# It will produce the final output
print ("\nThe Total marks is: \t", StudentData.CalcTotal(), "/", StudentData.CalcMaxMarks())
print ("\nThe Average marks is: \t", StudentData.CalcAvg())
print ("\nThe Percentage is: \t", StudentData.CalcPercentage(), "%")
print ("\nThe Grade is: \t", StudentData.CalcGrade())
print ("\nThe Result is: \t", StudentData.CalcResult())
```

### Output

`Enter the marks of five subjects::`

80

70

75

65

60

`The Total marks is: 350.0 / 500`

`The Average marks is: 70.0`

`The Percentage is: 70.0 %`

`The Grade is: C`

`The Result is: Passed`

**Note:**If the marks in each subject are**greater than or equal to 40**then Student will be passed otherwise It will fail.### Explanation

In the above program, we have taken some **objects** & **methods** to calculate and store the output values, It will be returned at end of the program:

#### Used Objects in the Program:

**Total**- To store the sum of total marks**Average**- To store an average of marks**Percentage**- To sore the percentage value of marks**Marks**- To store the marks of the given subject**MaxMarks**- To calculate maximum marks

#### Used Methods in the Program:

**main()**- it's a driver method**CalcMaxMarks()**- it will calculate maximum marks**CalcTotal()**- It will calculate total marks**CalcAvg()**- It will calculate the average of the marks**CalcPercentage()**- It will calculate the percentage of the total marks**CalcGrade()**- It will calculate the Grade of the student as per marks**CalcResult()**- It will define student passed or failed on behalf of its own marks

Visit this page to learn how to __Convert the Days into Years, Weeks, and Days in Python__