Program to calculate total marks, percentage and grade of a student. Marks obtained in each of the five subjects are to be input by user. Assign grades according to the following criteria: Grade A: Percentage >=80 Grade B: Percentage >=70 and <80, Grade C: Percentage >=60 and <70 Grade D: Percentage >=40 and <60, Grade E: Percentage <40.
# Input marks for five subjects
marks = [float(input(f"Enter marks for subject {i +
1}: "))for i in range(5)]
# Calculate total marks and percentage
total_marks = sum(marks)
percentage = (total_marks / 500) * 100
# Determine the grade based on the percentage
grades = {"A": 80, "B": 70,
"C": 60, "D": 40}
for grade, cutoff in grades.items():
if percentage
>= cutoff:
break
# Display the results
print(f"Total Marks: {total_marks}")
print(f"Percentage: {percentage:.2f}%")
print(f"Grade: Grade {grade}")
OUTPUT
Enter marks for subject 1: 87
Enter marks for subject 2: 98
Enter marks for subject 3: 100
Enter marks for subject 4: 67
Enter marks for subject 5: 89
Total Marks: 441.0
Percentage: 88.20%