jumboframe

Untitled

Mar 10th, 2021
577
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. n = int(input())
  2. students = {}
  3. for _ in range(n):
  4.     student, grade = input().split()
  5.     grade = float(grade)
  6.     if student not in students:
  7.         students[student] = []
  8.     students[student].append(grade)
  9.  
  10. for name, grades in students.items():
  11.     # grades_str = ' '.join(map(lambda g: f'{g:.2f}', grades))
  12.     grades_str = " ".join([f"{g:.2f}" for g in grades]) ## list comprehensions, why map and lambda functions? L.
  13.     average_grade = sum(grades) / len(grades)
  14.     print(f'{name} -> {grades_str} (average_grade: {average_grade:.2f})')
RAW Paste Data