Advertisement
Vladkoheca

Svetovna ranglista po tenis.py

Mar 11th, 2024
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | None | 0 0
  1. import math
  2.  
  3. # Четене на входните данни
  4. num_tournaments = int(input())
  5. starting_points = int(input())
  6.  
  7. # Инициализация на променливи
  8. final_points = starting_points
  9. won_tournaments = 0
  10.  
  11. # Обхождане на всички турнири
  12. for _ in range(num_tournaments):
  13.     tournament_result = input()
  14.  
  15.     if tournament_result == "W":
  16.         final_points += 2000
  17.         won_tournaments += 1
  18.     elif tournament_result == "F":
  19.         final_points += 1200
  20.     elif tournament_result == "SF":
  21.         final_points += 720
  22.  
  23. # Изчисляване на средните точки и процента на спечелени турнири
  24. total_points = final_points - starting_points
  25. average_points = math.floor(total_points / num_tournaments)
  26. percentage_won = (won_tournaments / num_tournaments) * 100
  27.  
  28. # Извеждане на резултатите
  29. print(f"Final points: {final_points}")
  30. print(f"Average points: {average_points}")
  31. print(f"{percentage_won:.2f}%")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement