197k views
0 votes
Use the get_seconds function to work out the amount of seconds in 2 hours and 30 minutes, then add this number to the amount of seconds in 45 minutes and 15 seconds. Then print the result.

User Richliaw
by
3.7k points

1 Answer

7 votes

Answer:

Since the get_seconds function is not given, I'll implement it myself;

The full program (get_seconds and main) written in python is as follows:

def get_seconds(hour,minute,seconds):

seconds = hour * 3600 + minute * 60 + seconds

return seconds

time1 = get_seconds(2,30,0)

time2 = get_seconds(0,45,15)

result = time1 + time2

print(result)

Step-by-step explanation:

The get_seconds defines hour, minute and seconds as its arguments

This line defines the get_seconds function

def get_seconds(hour,minute,seconds):

This line calculates the second equivalent of the time passed to the function

seconds = hour * 3600 + minute * 60 + seconds

This line returns the the calculated seconds equivalent of time

return seconds

The main starts here

This line calculates the number of seconds in 2 hours and 30 minutes

time1 = get_seconds(2,30,0)

This line calculates the number of seconds in 45 minutes and 15 seconds

time2 = get_seconds(0,45,15)

This line adds both together

result = time1 + time2

This line prints the result

print(result)

User Clevison Luiz
by
3.3k points