Advertisement
yordan_yordanov

06. Basketball Tournament

Aug 26th, 2020
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.14 KB | None | 0 0
  1. tournament_name = input()
  2.  
  3. games_won = 0
  4. games_lost = 0
  5. tournament_won = 0
  6. tournament_lost = 0
  7.  
  8. while tournament_name != 'End of tournaments':
  9.     games = int(input())
  10.     games_counter = 0
  11.  
  12.     for game in range(games):
  13.         score_team_desi = int(input())
  14.         score_opposing_team = int(input())
  15.         games_counter += 1
  16.  
  17.         if score_team_desi > score_opposing_team:
  18.             games_won += 1
  19.             print(f'Game {games_counter} of tournament {tournament_name}: win with '
  20.                   f'{score_team_desi - score_opposing_team} points.')
  21.         else:
  22.             games_lost += 1
  23.             print(f'Game {games_counter} of tournament {tournament_name}: lost with '
  24.                   f'{score_opposing_team - score_team_desi} points.')
  25.  
  26.         if games_won > games_lost:
  27.             tournament_won += 1
  28.         else:
  29.             tournament_lost += 1
  30.  
  31.     tournament_name = input()
  32.  
  33. percentage_won = (tournament_won / (games_won + games_lost)) * 100
  34. percentage_lost = (tournament_lost / (games_won + games_lost)) * 100
  35. print(f'{percentage_won:.2f}% matches win')
  36. print(f'{percentage_lost:.2f}% matches lost')
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement