Give seconds as input,write a program to print in D days H hours M minutes S seconds
Input 200
Output 3 minutes 20seconds
Input 86400
Output 1 day
t = int(input("Enter number of seconsd: "))
d = t // 86400
t = t % 86400
h = t // 3600
t = t % 3600
m = t // 60
s = t % 60
if d > 1:
print(f'{d} days', end=' ')
if d == 1:
print('1 day', end=' ')
if h > 1:
print(f'{h} hours', end=' ')
if h == 1:
print('1 hour', end=' ')
if m > 1:
print(f'{m} minutes', end=' ')
if m == 1:
print('1 minute', end=' ')
if s > 1:
print(f'{s} seconds')
if s == 1:
print('1 second')
if s == 0:
print()
Comments
Leave a comment