Advertisement
Spocoman

Exam Schedule

Oct 12th, 2023
1,094
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. hours = int(input())
  2. minutes = int(input())
  3. day_part = input()
  4. hours_added = int(input())
  5. minutes_added = int(input())
  6.  
  7. result = (hours + hours_added) * 60 + minutes + minutes_added
  8. total_hours = int(result / 60 % 24)
  9. total_minutes = result % 60
  10.  
  11. day_part = ("PM" if day_part == "AM" else "AM") if total_hours >= 12 else day_part
  12. total_hours -= 12 if total_hours > 12 else 0
  13.  
  14. print(f"{total_hours:02}:{total_minutes:02}:{day_part}")
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement