write a program to print in D days H hours M minutes S seconds
time_in_seconds = 1234567
# Seconds_Per_Minute = 60
# Seconds_Per_Hour = 3600
# Seconds_Per_Day = 86400
days = time_in_seconds // 86400
hours = (time_in_seconds - days * 86400) // 3600
minutes = (time_in_seconds - days * 86400 - hours * 3600) // 60
seconds = time_in_seconds - days * 86400 - hours * 3600 - minutes * 60
if days > 0:
print(days +' Days', end=' ')
if hours > 0:
print(hours +' Hours', end=' ')
if minutes > 0:
print(minutes, 'Minutes', end=' ')
if seconds > 0:
print(seconds, 'Seconds', end=' ')
print()
Comments
Leave a comment