Advertisement
nevenailievaa

08. On Time for the Exam

Nov 27th, 2024
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. hour_of_exam = int(input())
  2. minutes_of_exam = int(input())
  3. hour_of_arrive = int(input())
  4. minutes_of_arrive = int(input())
  5.  
  6. total_exam_minutes = hour_of_exam * 60 + minutes_of_exam
  7. total_arrive_minutes = hour_of_arrive * 60 + minutes_of_arrive
  8. time_difference = total_arrive_minutes - total_exam_minutes
  9.  
  10. if time_difference > 0:
  11.     print("Late")
  12.     if time_difference < 60:
  13.         print(f"{time_difference} minutes after the start")
  14.     else:
  15.         hours_late = time_difference // 60
  16.         minutes_late = time_difference % 60
  17.         print(f"{hours_late}:{minutes_late:02d} hours after the start")
  18. elif -30 <= time_difference <= 0:
  19.     print("On time")
  20.     if time_difference < 0:
  21.         print(f"{abs(time_difference)} minutes before the start")
  22. else:
  23.     print("Early")
  24.     early_time = abs(time_difference)
  25.     if early_time < 60:
  26.         print(f"{early_time} minutes before the start")
  27.     else:
  28.         hours_early = early_time // 60
  29.         minutes_early = early_time % 60
  30.         print(f"{hours_early}:{minutes_early:02d} hours before the start")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement