Spocoman

07. Football League

Dec 26th, 2021 (edited)
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. stadium_capacity = int(input())
  2. football_fans = int(input())
  3. sector_a = 0
  4. sector_b = 0
  5. sector_v = 0
  6. sector_g = 0
  7.  
  8. for i in range(football_fans):
  9.     sector = input()
  10.     if sector == 'A':
  11.         sector_a += 1
  12.     elif sector == 'B':
  13.         sector_b += 1
  14.     elif sector == 'V':
  15.         sector_v += 1
  16.     elif sector == 'G':
  17.         sector_g += 1
  18.  
  19. print(f'{sector_a / football_fans * 100:.2f}%')
  20. print(f'{sector_b / football_fans * 100:.2f}%')
  21. print(f'{sector_v / football_fans * 100:.2f}%')
  22. print(f'{sector_g / football_fans * 100:.2f}%')
  23. print(f'{football_fans / stadium_capacity * 100:.2f}%')
  24.  
  25.  
  26. Фундаменталс решение:
  27.  
  28. stadium_capacity = int(input())
  29. football_fans = int(input())
  30. sectors = {'A': 0, 'B': 0, 'V': 0, 'G': 0}
  31.  
  32. for i in range(football_fans):
  33.     sectors[input()] += 1
  34.  
  35. for i in sectors:
  36.     print(f'{sectors[i] / football_fans * 100:.2f}%')
  37.  
  38. print(f'{football_fans / stadium_capacity * 100:.2f}%')
  39.  
Add Comment
Please, Sign In to add comment