Computer Science, asked by RudrakshaKapoor08, 7 hours ago

Write a program in python to input the roll number, name and marks in five subjects of a student.
Calculate the total and percentage marks of the student.

Answers

Answered by ansarikahekasha45
4

Explanation:

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'

Similar questions