Spocoman

Best Player

Jan 5th, 2022 (edited)
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.37 KB | None | 0 0
  1. best_player = ''
  2. goals = 0
  3. command = input()
  4. while command != "END":
  5.     goal = int(input())
  6.     if goal > goals:
  7.         best_player = command
  8.         goals = goal
  9.     if goals >= 10:
  10.         break
  11.     command = input()
  12. print(f'{best_player} is the best player!')
  13. if goals < 3:
  14.     print(f'He has scored {goals} goals.')
  15. else:
  16.     print(f'He has scored {goals} goals and made a hat-trick !!!')
  17.  
  18.  
  19. Решение с while и тернарен оператор:
  20.  
  21. best_player = ''
  22. goals = 0
  23. command = input()
  24. while command != "END":
  25.     goal = int(input())
  26.     best_player = command if goal > goals else best_player
  27.     goals = goal if goal > goals else goals
  28.     if goals >= 10:
  29.         break
  30.        
  31.     command = input()
  32.  
  33. print(f'{best_player} is the best player!')
  34. print(f'He has scored {goals} goals{"." if goals < 3 else " and made a hat-trick !!!"}')
  35.  
  36.  
  37. Решение с for и тернарен оператор :
  38.  
  39. import sys
  40.  
  41. best_player = ''
  42. goals = 0
  43.  
  44. for i in range(sys.maxsize-1):
  45.     command = input()
  46.     if command == "END":
  47.         break
  48.     goal = int(input())
  49.     best_player = command if goal > goals else best_player
  50.     goals = goal if goal > goals else goals
  51.     if goals >= 10:
  52.         break
  53.  
  54. print(f'{best_player} is the best player!')
  55. print(f'He has scored {goals} goals{"." if goals < 3 else " and made a hat-trick !!!"}')
  56.  
Add Comment
Please, Sign In to add comment