desislava_topuzakova

07. World Swimming Record

Mar 17th, 2021
852
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. # време за плуване = разстоянието * време за 1 м
  2. # забавяне = floor(разстоянието / 15) * 12.5 сек
  3. # времето на Иван = време за плуване + забавянето
  4. # проверка дали подобрява рекорда
  5.  
  6. from math import floor
  7. record = float(input())
  8. distance = float(input())
  9. time_per_meter = float(input())
  10.  
  11. swim_time = distance * time_per_meter
  12. delay_time = floor(distance / 15) * 12.5
  13. total_time = swim_time + delay_time
  14.  
  15.  
  16. if total_time < record:
  17.     # подобравя рекорда
  18.     print(f"Yes, he succeeded! The new world record is {total_time:.2f} seconds.")
  19. else:
  20.     # не подобрява рекорда
  21.     need_time = total_time - record
  22.     print(f"No, he failed! He was {need_time:.2f} seconds slower.")
Advertisement
Add Comment
Please, Sign In to add comment