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 contains single integer
N.
Output
Print space-separated integers
Y, W and D.
Explanation
Given
N = 1329. The 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 2
0
Sample Output 2
0
0
0
DAYS_PER_WEEK = 7
def findYearWeekDays( numberOfDays ):
year = int(numberOfDays / 365)
week = int((numberOfDays % 365) /
DAYS_PER_WEEK)
days = (number_of_days % 365) % DAYS_PER_WEEK
print("Years = ",year,
"\nweeks = ",week,
"\ndays = ",days)
#Testing code
number_of_days =1329
findYearWeekDays(number_of_days)
Comments
Leave a comment