Answer to Question #318484 in Python for years, weeks

Question #318484

years,weeks & days


Given N number of days as input , write a program to convert N number of days to years ( ( Y ) weeks ( W ) and days ( D ).

NOTE :Take 1 year = 365 days.


input

the input contain single line integer N .


output

print space-separated integers Y , W and D.


Explanation

Given N =1329 . th value can be written as 1329 = 3 years +33 weeks + 3 days

so the output should be 3 33 3 .


sample input 1

1329


sample output 1

3

33

3


sample input 1



sample output 1





1
Expert's answer
2022-03-28T08:02:54-0400

Use the following program:

# Number of days
# prompt the user to enter number of days
days = int(input("Enter number of days: "))

# perform the calculations
years = days // 365
if years > 0:
    print(years, "years", end=" ")
weeks = (days - years * 365) // 7
if weeks > 0:
    print(weeks, "weeks", end=" ")
days = days - years * 365 - weeks * 7
if days > 0:
    print(days, "days")
else:
    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