aneliabogeva

On Time for the Exam

May 7th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. import math
  2. hour = int(input())
  3. min = int(input())
  4. arrivedhour = int(input())
  5. arrivedmin = int(input())
  6. exam_time = hour * 60 + min
  7. arrived_time = arrivedhour * 60 + arrivedmin
  8. time_difference = abs(arrived_time-exam_time)
  9.  
  10. if arrived_time == exam_time:
  11. print("On time")
  12. elif arrived_time < exam_time and time_difference <= 30:
  13. print("On time")
  14. print(f"{time_difference} minutes before the start")
  15.  
  16. elif arrived_time < exam_time and time_difference > 30 and time_difference < 60:
  17. print("Early")
  18. print(f"{time_difference} minutes before the start")
  19.  
  20. elif arrived_time < exam_time and time_difference >= 60:
  21. print("Early")
  22. hours = math.floor(abs(arrived_time - exam_time) // 60)
  23. minutes = abs(arrived_time - exam_time) % 60
  24. if minutes < 10:
  25. print(f"{hours}:0{minutes} hours before the start")
  26. else:
  27. print(f"{hours}:{minutes} hours before the start")
  28.  
  29. elif arrived_time > exam_time:
  30. print("Late")
  31. if abs(arrived_time-exam_time) < 60:
  32. print(f"{abs(arrived_time-exam_time)} minutes after the start")
  33. else:
  34. hours = math.floor(abs(arrived_time-exam_time)//60)
  35. minutes = abs(arrived_time-exam_time) %60
  36. if minutes < 10:
  37. print(f"{hours}:0{minutes} hours after the start")
  38. else:
  39. print(f"{hours}:{minutes} hours after the start")
Advertisement
Add Comment
Please, Sign In to add comment