Advertisement
Spocoman

08. On Time for the Exam

Dec 21st, 2021 (edited)
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.63 KB | None | 0 0
  1. hour_exam = int(input())
  2. minute_exam = int(input())
  3. hours_student = int(input())
  4. minute_student = int(input())
  5. exam_minutes = hour_exam * 60 + minute_exam
  6. student_minutes = hours_student * 60 + minute_student
  7. diff = abs(exam_minutes - student_minutes)
  8.  
  9. if student_minutes > exam_minutes:
  10.     print("Late")
  11.     if diff < 60:
  12.         print(f'{diff} minutes after the start')
  13.     else:
  14.         print(f'{diff // 60}:{diff % 60:02} hours after the start')
  15. else:
  16.     if 0 <= diff <= 30:
  17.         print('On time')
  18.     else:
  19.         print('Early')
  20.     if 0 < diff < 60:
  21.         print(f'{diff} minutes before the start')
  22.     elif diff != 0:
  23.         print(f'{diff // 60}:{diff % 60:02} hours before the start')
  24.  
  25.  
  26. РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
  27.  
  28. hour_exam = int(input())
  29. minute_exam = int(input())
  30. hours_student = int(input())
  31. minute_student = int(input())
  32.  
  33. diff = (hour_exam * 60 + minute_exam) - (hours_student * 60 + minute_student)
  34.  
  35. print('On time' if 0 <= diff <= 30 else 'Early' if diff > 30 else 'Late')
  36. print(f'{abs(diff)} minutes {"before" if diff > 0 else "after"} the start' if 0 < abs(diff) < 60 else
  37.       f'{abs(diff) // 60}:{abs(diff) % 60:02} hours {"before" if diff > 0 else "after"} the start')
  38.  
  39.  
  40. И ЛЕКО ТАРИКАТСКАТА:)
  41.  
  42. diff = (int(input()) * 60 + int(input())) - (int(input()) * 60 + int(input()))
  43.  
  44. print('On time' if 0 <= diff <= 30 else 'Early' if diff > 30 else 'Late')
  45. print(f'{abs(diff)} minutes {"before" if diff > 0 else "after"} the start' if 0 < abs(diff) < 60 else
  46.       f'{abs(diff) // 60}:{abs(diff) % 60:02} hours {"before" if diff > 0 else "after"} the start')
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement