Question: SORT CLASS RANKING GIVEN GRADES AND SUBJECTS Here is what one of my friends and I tried but it doesn't quite work. I can't figure

SORT CLASS RANKING GIVEN GRADES AND SUBJECTS
Here is what one of my friends and I tried but it doesn't quite work. I can't figure out how to get rid of the grades and just have names:
def ranking(grades, subject):
------grade_dict = {}
------for student in grades:
--------------student_grades = grades[student]
--------------numSubjects = 0
---------------totalScore = 0
---------------grade = 0
grade_dict[student] = grades.get(student).get(subject).get("Tests")
return sorted(grade_dict.items() , reverse=True, key=lambda x: x[1])
Determine class ranking Ranking is determined by simply using the test percentage. 1 def ranking (grades, subject): 2 [] 1 2 observed = ranking (grades, "Algebra") expected [ "Felicity", "Curtis", "Oliver", "John" ] assert observed == expected, f" You returned: = 3 {observed!r} instead of: {expected!r}" 4 5 6 observed = ranking (grades, "Physics") expected ["Felicity", "Curtis", "Oliver" ] assert observed expected, f" You returned: = 7 == {observed!r} instead of: {expected!r}" Determine class ranking Ranking is determined by simply using the test percentage. 1 def ranking (grades, subject): 2 [] 1 2 observed = ranking (grades, "Algebra") expected [ "Felicity", "Curtis", "Oliver", "John" ] assert observed == expected, f" You returned: = 3 {observed!r} instead of: {expected!r}" 4 5 6 observed = ranking (grades, "Physics") expected ["Felicity", "Curtis", "Oliver" ] assert observed expected, f" You returned: = 7 == {observed!r} instead of: {expected!r}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
