Question: Part III: Time Conversions (4 points) The file problem3. contains a single function named get seconds ( ). This function takes exactly one argument: an
Part III: Time Conversions (4 points) The file "problem3." contains a single function named get seconds ( ). This function takes exactly one argument: an 8-character string representing an amount of time in the form HH:MM:SS, where HH represents a number of hours, MM represents a number of minutes, and SS represents a number of seconds. get Seconds returns a positive integer representing the total number of seconds in the input. For example, the time value "02 : 18: 4 9" (2 hours, 18 minutes, and 49 seconds) corresponds to a total of 8329 seconds: there are 3600 seconds in an hour and 60 seconds in a minute, so we have (2 3600)+(18 60) +49, which adds up to 8329 You may assume that the number of hours always falls in the range 00-99 (inclusive), the number of minutes always falls in the range 00-59 (inclusive), and the number of seconds always falls in the range 00-59 (inclusive) HINT: Use string slicing to extract each of the three time fields (hours, minutes, and seconds) from the function parameter. Each slice is still a string, so you wll need to convert it to an integer before you can perform any arithmetic with it (in class we discussed a function for doing this) Examples: Function Call etSeconds ("11:11:14") getSeconds ("00:01:02") getSeconds ("05:00:30") getSeconds ("00:00:00" Return Value 40274 62 18030
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
