Answer to Question #295307 in Python for Varshitha

Question #295307

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

1
Expert's answer
2022-02-08T11:42:17-0500
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()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS