Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_student_name(students):
- """
- This function takes a dictionary of students and their grades
- and returns the name(s) of the student(s) with the lowest grade above the minimum grade
- """
- min_grade = min(students.values())
- # sort the dictionary by values
- students = sorted(students.items(), key=lambda x: x[1])
- results = []
- result = None
- for name, grade in students:
- if grade > min_grade and not results:
- results.append(name)
- result = grade
- elif grade == result:
- results.append(name)
- else:
- continue
- return results
- students = {'r': 0, 'b': 0, 'c': 3, 'n': 10, 'e': 50 , 'a': 3}
- print(get_student_name(students))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement