In: Computer Science
AverageGrade. Assume the professor gives five exams during the semester with grades 0 through 100 and drops one of the exams with the lowest grade. Write a program to find the average of the remaining four grades. The program should use a class named Exams that has
1. An instance variable to hold a list of five grades,
2. A method that calculate and return average.
3. A string that return the “exams Average” for printing.
Your program output should prompt for an input for each grade. Use any number between 0 and 100. Your submission should include compiled output.
Answer:- We are using Python 3 Programming language for this problem.
Python Program (Use Python 3 compiler for execute)
class Exams:
instance=[] #An instance variable to hold a list of five grades
# A method that calculate and return average.
for i in range(5):
a=int(input('Please Enter Grade: '))
instance.append(a)
instance = sorted(instance) # To sort string in ascending order
Sum=0
for i in range(1,5):
Sum=instance[i]+Sum
# A string that return the “exams Average” for printing.
print('Exam average: ',Sum/4)
Output:-
If you need any help in understanding, Please comment your query.
I tried my best for this question, I hope you upvote my answer.
Thank You