Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- many = int(input())
- students_dict = {}
- for _ in range(many):
- student, grade = input(), float(input())
- if student not in students_dict:
- students_dict[student] = []
- students_dict[student].append(grade)
- students_avg_dict = dict([(key, sum(value) / len(value))
- for (key, value) in students_dict.items()])
- students_fil_dict = dict([(k, v)
- for (k, v) in students_avg_dict.items() if v >= 4.5])
- students_sorted_dict = dict(sorted(students_fil_dict.items(), key=lambda x: x[1], reverse=True))
- for k, v in students_sorted_dict.items():
- print(f'{k} -> {v:.2f}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement