Python: Convert seconds to day, hour, minutes and seconds
Python Basic: Exercise-65 with Solution
Write a Python program to convert seconds to day, hour, minutes and seconds.
Sample Solution:-
time = float(input("Input time in seconds: "))
day = time // (24 * 3600)
time = time % (24 * 3600)
hour = time // 3600
time %= 3600
minutes = time // 60
time %= 60
seconds = time
print("d:h:m:s-> %d:%d:%d:%d" % (day, hour, minutes, seconds))
========== RESTART: F:/Python_APSC/py-ex-basic-65.py ===========
Input time in seconds: 20000
d:h:m:s-> 0:5:33:20
>>>
=========== RESTART: F:/Python_APSC/py-ex-basic-65.py ==========
Input time in seconds: 36005
d:h:m:s-> 0:10:0:5
>>>
沒有留言:
張貼留言