simeonshopov

Student Academy

Feb 4th, 2020
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. students = {}
  2.  
  3. n = int(input())
  4.  
  5. for i in range(n):
  6.     student = input()
  7.     grade = float(input())
  8.  
  9.     if student not in students:
  10.         students[student] = [grade, 1]
  11.     else:
  12.         students[student][0] += grade
  13.         students[student][1] += 1
  14.  
  15. for student in students:
  16.     students[student] = students[student][0] / students[student][1]
  17.  
  18. new = sorted(students, key=lambda x: students[x], reverse=True)
  19.  
  20. [print(f'{x} -> {students[x]:.2f}') for x in new if students[x] >= 4.5]
Advertisement
Add Comment
Please, Sign In to add comment