Advertisement
endzie_fyrge

[10] Passed Time

Jul 4th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. start_time = input("Enter the time in format HH:MM:SS: ")
  2. end_time = input("Enter the time in format HH:MM:SS: ")
  3.  
  4. start_seconds = int(start_time[0] + start_time[1]) * 3600 + int(start_time[3] + start_time[4]) * 60 + int(start_time[6] + start_time[7])
  5. end_seconds = int(end_time[0] + end_time[1]) * 3600 + int(end_time[3] + end_time[4]) * 60 + int(end_time[6] + end_time[7])
  6.  
  7. hours = (end_seconds - start_seconds) // 3600
  8. minutes = ((end_seconds - start_seconds) // 60) % 60
  9. seconds = (end_seconds - start_seconds) % 60
  10.  
  11. print(f"The time that passed is {hours}:{minutes}:{seconds}.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement