Question: PYTHON a. Write a function with the following specifications: format_time(hour, minute, second)- Arguments for hours, minutes, and seconds are integers. If hour, minute or second

PYTHON

a. Write a function with the following specifications:

format_time(hour, minute, second)- Arguments for hours, minutes, and seconds are integers.

If hour, minute or second have invalid values, the function returns invalid time, otherwise it returns the time as hh:mm:ss (for example 02:45:06).

We will assume that we use a 24 hour-clock, so to be valid hour must be between 0 and 23 and minute and second between 0 and 59.

Your solution must use the join() method.

Hint: Convert and format the integer arguments (for hour, minute and second) before using the join method.

b. Write a program to test your function by calling it with the arguments listed below and printing each output.

You must add ALL the function calls to the program so you can just test it with ONE run (but you might have to run the program several times if you need to correct errors!)

Before each method call you should include a print statement that indicates the expected output.

13, 45, 23

3, 5, 6

24, 34, 34

2, 60, 24

12, 0, 65

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!