Flesh out the body of the print_seconds function so that it prints the total amount of seconds given the hours, minutes, and seconds function parameters. Remember that there are 3600 seconds in an hour and 60 seconds in a minute.
using python
Answers
Answer:
def print_seconds(int hours,int minutes ,int seconds)
{
print((hours*3600) + (minutes*60) + seconds)
}
Explanation:
you can also calculate total seconds in the given hours and minutes and store it in separate variable ,i.e,
h=hours*3600
m=minutes*60
and then add
print(h+m+seconds)
Answer:
The python program to find the print_seconds function was given below. The out for the given python program was found to be 3723.
Explanation:
To print_seconds function :
The total amount of seconds was given in hours , minutes and seconds function parameters.
Given,
- 3600 seconds in an hour
- 60 seconds in a minute
Algorithm :
def time ( hours , minutes , seconds ):
total = hours * 3600
total += minutes* 60
total += seconds
print (f" with {hours} hours, {minutes} minutes , {seconds} seconds, the total second is {total}" )
time (1, 2, 3)
Another method:
def_seconds (hours, minutes, seconds):
total_seconds= hours*3600+minutes*60+seconds
print(total_seconds)
print(1,2,3)
Output:
3723
#SPJ2