Answer to Question #299335 in Python for Anitha

Question #299335

write a program to print in D days H hours M minutes S seconds

1
Expert's answer
2022-02-18T07:31:19-0500
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()

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