krstoilo

On Time for the Exam

May 7th, 2020
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.18 KB | None | 0 0
  1. exam_hour = int(input())
  2. exam_minute = int(input())
  3. arrival_hour = int(input())
  4. arrival_minute = int(input())
  5.  
  6. exam_time = (exam_hour * 60) + exam_minute
  7. arrival_time = (arrival_hour * 60) + arrival_minute
  8.  
  9. if exam_time == arrival_time:
  10.     print("On time")
  11. elif exam_time > arrival_time:
  12.     result = exam_time - arrival_time
  13.     if result <= 30:
  14.         print("On time")
  15.         print(f'{result} minutes before the start')
  16.     elif 30 < result < 60:
  17.         print("Early")
  18.         print(f'{result} minutes before the start')
  19.     if result >= 60:
  20.         print("Early")
  21.         h = result / 60
  22.         m = result % 60
  23.         if m <= 9:
  24.             print(f'{int(h)}:0{m} hours before the start')
  25.         else:
  26.             print(f'{int(h)}:{m} hours before the start')
  27. elif arrival_time > exam_time:
  28.     result = arrival_time - exam_time
  29.     if result < 60:
  30.         print("Late")
  31.         print(f'{result} minutes after the start')
  32.     elif result >= 60:
  33.         print("Late")
  34.         h = result / 60
  35.         m = result % 60
  36.         if m <= 9:
  37.             print(f'{int(h)}:0{m} hours after the start')
  38.         else:
  39.             print(f'{int(h)}:{m} hours after the start')
Add Comment
Please, Sign In to add comment