2018年1月9日 星期二

Python: Convert seconds to day, hour, minutes and seconds

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
>>> 

沒有留言:

張貼留言

RFID Super Tag 協議模擬器

RFID Super Tag 協議模擬器 Super Tag 協議 (通常指一種改進型的時分多址或樹狀抗碰撞協議)的核心概念是「標籤主導」與「快速識別」。在這種模式下,標籤不僅僅是等待查詢,還會根據內部的計數器或隨機分配的 Slot 進行主動回應,而 Reader 則根據回應情況...