Answer to Question #176589 in Python for adhi chinna

Question #176589

Days Conversion

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


The input will be a single line containing a positive integer (N).Output


The output should be a single line containing years, weeks, days values separated by spaces.Explanation


For example, if the given number of days (N) is 1329.

1329 = 365*3 + 33*7 + 3

So the output is 3 years 33 weeks 3 days


1
Expert's answer
2021-03-29T06:12:48-0400
days = int(input("Enter number of days: "))
years = days // 365
if years > 0:
    print(years, "years", end = " ")
weeks = (days - years * 365) // 7
if weeks > 0:
    print(weeks, "weeks", end = " ")
newDays = days - years * 365 - weeks * 7
if newDays > 0:
    print(newDays, "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
APPROVED BY CLIENTS