Advertisement
PowerCell46

On time for the exam Python

Dec 16th, 2022
696
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.77 KB | None | 0 0
  1. hour_of_the_exam = int(input())
  2. minute_of_the_exam = int(input())
  3. hour_of_arrival = int(input())
  4. minute_of_arrival = int(input())
  5.  
  6. start_of_the_exam = hour_of_the_exam * 60 + minute_of_the_exam
  7. coming_to_the_exam = hour_of_arrival * 60 + minute_of_arrival
  8. output = ""
  9. final_minutes = 0
  10. final_hours = 0
  11.  
  12. if coming_to_the_exam <= start_of_the_exam and start_of_the_exam - coming_to_the_exam <= 30: ## On time
  13.     output = "On time"
  14.     final_minutes = start_of_the_exam - coming_to_the_exam
  15.     if final_minutes == 0:
  16.         print(output)
  17.     else:
  18.         print(output)
  19.         print((f'{final_minutes} minutes before the start'))
  20.  
  21. elif start_of_the_exam - coming_to_the_exam > 30: ## Early
  22.     output = "Early"
  23.     final_minutes = start_of_the_exam - coming_to_the_exam
  24.     if final_minutes >= 60:
  25.         while final_minutes >= 60:
  26.             final_minutes -= 60
  27.             final_hours += 1
  28.         print(output)
  29.         if final_minutes < 10:
  30.             print(f'{final_hours}:0{final_minutes} hours before the start')
  31.         else:
  32.             print(f'{final_hours}:{final_minutes} hours before the start')
  33.     else:
  34.         print(output)
  35.         print(f'{final_minutes} minutes before the start')
  36.  
  37. elif coming_to_the_exam > start_of_the_exam:
  38.     output = "Late"
  39.     final_minutes = coming_to_the_exam - start_of_the_exam
  40.     if final_minutes >= 60:
  41.         while final_minutes >= 60:
  42.             final_minutes -= 60
  43.             final_hours += 1
  44.         print(output)
  45.         if final_minutes < 10:
  46.             print(f'{final_hours}:0{final_minutes} hours after the start')
  47.         else:
  48.             print(f'{final_hours}:{final_minutes} hours after the start')
  49.     else:
  50.         print(output)
  51.         print(f'{final_minutes} minutes after the start')
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement