Answer to Question #221452 in Python for srikanth

Question #221452
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
1
Expert's answer
2021-07-29T23:31:45-0400


 
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)








 

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