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
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("")
Comments
Leave a comment