desislava_topuzakova

6. Великденски конкурс

May 22nd, 2021
1,145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.18 KB | None | 0 0
  1. import sys
  2. easter_bread_count = int(input())
  3. max_points = -sys.maxsize # най - големите изкарани точки
  4. best_baker = '' #името на пекаря с най-много точки
  5.  
  6. #за всеки един козунак от 1 до последния -> чета името на пекар
  7. for bread in range(1, easter_bread_count + 1):
  8.     baker_name = input()
  9.     total_points_per_baker = 0
  10.     # четем точки до Stop
  11.     # STOP: command == "Stop" -> command != "Stop"
  12.     command = input() # точки или Stop
  13.     while command != "Stop":
  14.         # точки -> command = "12" -> int
  15.         points = int(command)
  16.         total_points_per_baker += points
  17.  
  18.         command = input()
  19.     else: #command == "Stop"
  20.         print(f"{baker_name} has {total_points_per_baker} points.")
  21.         # проверка дали неговите точки са максималните
  22.         if total_points_per_baker > max_points:
  23.             max_points = total_points_per_baker
  24.             best_baker = baker_name
  25.             print(f'{best_baker} is the new number 1!')
  26.  
  27.  
  28.  
  29. print(f'{best_baker} won competition with {max_points} points!')
  30.  
  31.  
Advertisement
Add Comment
Please, Sign In to add comment