Answer to Question #344733 in Python for Naveen

Question #344733

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"

Sample Input 1

200

Sample Output 1

3 Minutes 20 Seconds


Sample Input 2

86400

Sample Output 2

1 Days


1
Expert's answer
2022-05-25T10:22:55-0400
time_seconds = int(input())
constand_dict = {'Days': 86400, 'Hours': 3600, 'Minutes': 60, 'Seconds': 1}
time_string = ''
for key in constand_dict.keys():
	counter = time_seconds // constand_dict[key]
	if  counter != 0:
		time_string += f'{counter} {key} '
		time_seconds = time_seconds % constand_dict[key]
print(time_string)

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