Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part IV: Determine the Ending Time (25 points) Write a function ending time() that determines the final clock time after a task has been completed.

image text in transcribed
Part IV: Determine the Ending Time (25 points) Write a function ending time() that determines the final clock time after a task has been completed. The function takes three arguments that provide the current time of day, as well as the total time in seconds that it will take to complete the task: 1 hour: the current hour of the day (0-23) 2. minute: the current minute of the day (0 - 59) 3. second: the current second of the day (0-59) 4. time_taken the number of seconds it will take to complete the task (greater than ) You may assume that the four input values are always valid. As an example of what this function computes, consider the test case: 2.59.40.22. This means that the current hour is 2, the current minute is 59, the current second is 40, and the time to complete the task is 22 seconds. So the first three function arguments represent the time 2.59:40 am Adding time taken to the current second value updates the second value to 62. Because 62 seconds is 60 (ie, at least one minute), the current second value is updated to 2. The minute value must also be incremented by 1 minute, to 60. Similar to how we handled the second value, the minute is set to mere because we have a whole new hour. Finally, the hour value must be incremented by I because minute rolled over from 5 to 60 and then too. This produces the final result of 3.0, and 2 for hour, minute and second, respectively. The return value of the function is an f-string given in this format: 'h:m:s', where h gives the updated hour, gives the updated minute, and s gives the updated second. To keep things simple the returned string should not include leading zeroes. As an example, if the new values for hour, minute and second are 59 and 2. the returned value should simply be the string '5:9:2'. not'05:09:02'. Answers that contain leading zeroes will be marked as incorrect Examples: CSE 101 - Spring 2020 Homework #1 Function Arguments Return value 2. 59, 40, 22 3 :0:2 5, 11, 24,6 5:11:30 4, 11, 25, 236 4:15:21 11, 54, 56, 340 12:0:36' 22, 52, 48, 8000 '1:6:8 17, 17, 5, 31688 12:5:13' 19, 6, 53, 7500 21:11:53 20, 34, 35, 26770 4:0:45' 19, 54, 3, 15463 0:11:46 18, 21, 35, 268751:49:30

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions