Advertisement
Guest User

Untitled

a guest
Dec 10th, 2021
640
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. from collections import OrderedDict
  2. number_of_rows = int(input())
  3.  
  4. list_of_students = []
  5. list_of_grades = []
  6.  
  7. current_row = 1
  8.  
  9. for number in range(1, number_of_rows * 2 + 1):
  10.     information = input()
  11.  
  12.     if current_row % 2 == 0:
  13.         list_of_grades.append(information)
  14.     else:
  15.         list_of_students.append(information)
  16.  
  17.     current_row += 1
  18.  
  19. list_of_grades = [float(i) for i in list_of_grades]
  20.  
  21. information_list = {}
  22.  
  23. for name, grade in zip(list_of_students, list_of_grades):
  24.     if name not in information_list:
  25.         information_list[name] = grade
  26.     else:
  27.         information_list[name] = float((information_list[name] + grade) / list_of_students.count(name))
  28.  
  29. orderDict = OrderedDict(sorted(information_list.items(), key=lambda kv: kv[1], reverse=True))
  30.  
  31. for name in orderDict:
  32.     grade = orderDict[name]
  33.     if grade >= 4.50:
  34.         print(f"{name} -> {grade:.2f}")
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement