svephoto

Basketball Tournament [python]

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