Advertisement
Guest User

on_time

a guest
Feb 23rd, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. exam_hour = int(input())
  2. exam_minutes = int(input())
  3. arrive_hour = int(input())
  4. arrive_minutes = int(input())
  5.  
  6. exam_in_minutes = exam_hour * 60 + exam_minutes
  7. arrive_in_minutes = arrive_hour * 60 + arrive_minutes
  8.  
  9. late = arrive_in_minutes - exam_in_minutes
  10. early = exam_in_minutes - arrive_in_minutes
  11.  
  12. diff = abs(late)
  13. hours = diff // 60
  14. minutes = diff % 60
  15.  
  16. if late > 0:
  17.     print(f'Late')
  18.     if late <= 59:
  19.         print(f'{late} minutes after the start')
  20.     else:
  21.         print(f'{hours}:{minutes:02d} hours after the start')
  22. elif 0 <= early <= 30:
  23.     print(f'On time')
  24.     if early != 0:
  25.         print(f'{early} minutes before the start')
  26. elif early > 30:
  27.     print('Early')
  28.     if early <= 59:
  29.         print(f'{early} minutes before the start')
  30.     else:
  31.         print(f'{hours}:{minutes:02d} hours before the start')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement