Modify the code in this program to include following:
a. refactor the script into a function, get_grades(),which returns a dictionary containing
the grade (number of correct answers) achieved per student;
b. write a new function, sorted_by_grade(), which displays students in ascending order of
the grade they achieved; and
c. write a new function, main(), which simply calls the functions you defined in a and b above
<pre>student_answers = {
"Adam": ['A', 'B', 'A', 'C', 'C', 'D', 'A', 'D', 'A', 'E'],
"Bob": ['D', 'B', 'A', 'B', 'C', 'A', 'C', 'D', 'A', 'E'],
"Carol":['A', 'C', 'D', 'A', 'C', 'B', 'C', 'D', 'A', 'E'],
"Jon": ['C', 'B', 'A', 'E', 'D', 'C', 'A', 'D', 'A', 'E'],
"Liz": ['A', 'B', 'A', 'C', 'A', 'E', 'D', 'E', 'A', 'E'],
"Marc": ['A', 'C', 'D', 'C', 'C', 'D', 'A', 'D', 'A', 'E'],
"Mia": ['B', 'B', 'E', 'C', 'A', 'D', 'A', 'D', 'A', 'E'],
"Zia": ['E', 'B', 'E', 'C', 'A', 'E', 'C', 'E', 'A', 'E']
}
# Key to the questions
model_answers = ['A', 'C', 'D', 'C', 'A', 'D', 'A', 'D', 'A', 'E']
# Grade all answers
for name in student_answers:
# Grade for one student
correctCount = 0
for j in range(len(student_answers[name])):
if student_answers[name][j] == model_answers[j]:
correctCount += 1
print(name, "achieved", correctCount, "correct answers.")</pr
What I have tried:
I have done this but as you can see it above i am not able to do it Please help me to do this code.