In: Computer Science
Write a program that asks the user for a number of seconds and
tells them how
many hours, minutes and seconds it is. Make sure your program works
correctly
for values smaller than the whole hour or whole minute. Here’s what
the sample
output from several runs of your program would look like:
Please enter the number of seconds: 2
2 seconds
>>>
Please enter the number of seconds: 500
8 minutes 20 seconds
>>>
Please enter the number of seconds: 20000
5 hours 33 minutes 20 seconds
Hint: you may find mod and div operations helpful here. You will
need to use
branching statements (ifs) in this program.
use python
seconds = int(input("Please enter the number of seconds: "))
#finding hours
hours=seconds//3600
seconds = seconds%3600
#finding min
minutes = seconds//60
seconds = seconds%60
if(hours!=0):
print(hours," hours",end=" ")
if(minutes!=0):
print(minutes," minutes ",end="")
if(seconds!=0):
print(seconds," seconds ",end="")
Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me