This problem builds on POTD 10. Today’s program takes two times of day, expressed in 24-hour hh:mm:ss format, and prints the elapsed time between them, expressed in total seconds. To accomplish this, you will implement two new functions:
to_seconds
takes a number of hours, minutes, and
seconds, and converts it to a raw number of seconds. This is essentially
the inverse of the get_hours
, get_minutes
, and
get_seconds
functions from P10.timediff
takes six arguments, representing the hours,
minutes, and seconds of a start and an end time. The function returns
the raw number of seconds elapsed between the two times. For now, we
assume that the ending time is later than the starting time.The main program has been written for you. Note that the main program
makes use of the print_hms
function from P10, so you’ll
need P10_hms.py
in the same directory as your
P11_timediff.py
file so the function from P10 can be
imported.
Here’s an example run of the program, with input times 10:04:04 and 12:03:00:
>>> %Run P11_timediff.py 10 04 04 12 03 00
01:58:56
None! Check out the problems from Lecture 10 for practice with writing your own functions.