Advertisement
svephoto

Basketball Tournament [python]

Dec 1st, 2019
763
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. input_text = input()
  2.  
  3. win_counter = 0
  4. loss_counter = 0
  5. game_counter = 0
  6. total_game_counter = 0
  7.  
  8. while input_text != "End of tournaments":
  9.     number_of_games = int(input())
  10.  
  11.     for x in range(0, number_of_games):
  12.         game_counter += 1
  13.         total_game_counter += 1
  14.  
  15.         desi_team = int(input())
  16.         other_team = int(input())
  17.  
  18.         if desi_team > other_team:
  19.             win_counter += 1
  20.             print(f"Game {game_counter} of tournament {input_text}: win with {desi_team - other_team} points.")
  21.  
  22.         if desi_team < other_team:
  23.             loss_counter += 1
  24.             print(f"Game {game_counter} of tournament {input_text}: lost with {other_team - desi_team} points.")
  25.  
  26.     game_counter = 0
  27.     input_text = input()
  28.  
  29. win_percentage = win_counter * 1.00 / total_game_counter * 100
  30. loss_percentage = loss_counter * 1.00 / total_game_counter * 100
  31.  
  32. print(f"{win_percentage:.2f}% matches win")
  33. print(f"{loss_percentage:.2f}% matches lost")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement