Answer to Question #178675 in Python for chandu

Question #178675

Date Format - 2

Given seconds as input, write a program to print in D days H hours M minutes S seconds.Input


The input will be a single line containing an integer.Output


The output should be a single line containing the D Days H Hours M Minutes S Seconds format. Print only the non-zero values.Explanation


For example, if the given seconds are 200. As 200 seconds is equal to 3 minutes and 20 seconds, and days, hours are zero, so ignore the days and hours. So the output should be "3 Minutes 20 Seconds"


output is like if we give as input like 3600 output like 3 min 20sec


and input is like 86400 the output should be like 1 day


1
Expert's answer
2021-04-07T04:04:37-0400
def pr_nozero(*arg):
    if arg[0]:
        print(*arg,end =' ')

sec = int(input('Enter a positive integer number of seconds: '))
pr_nozero(sec//86400, 'day')
pr_nozero(sec//3600%24, 'hour')
pr_nozero(sec//60%60, 'min')
pr_nozero(sec%60, 'sec')

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