Python: Write a python program to input number of days from user and convert it to years, weeks and days.

Program 6. Write a python program to input number of days from user and convert it to years, weeks and days. How to convert days to years, weeks in python programming. Logic to convert days to years, weeks and days in python program.

For Example
Input
Enter days: 373
Output
373 days = 1 year/s, 1 week/s and 1 day/s
Days conversion formula
1 year = 365 days (Ignoring leap year)
1 week = 7 days

Using this we can define our new formula to compute years and weeks.
year = days / 365
week = (days – (year * 365)) / 7
Logic to convert days to years weeks and days
Step by step descriptive logic to convert days to years, weeks and remaining
days is given below –
1. Read total days from user in some variable say days.
2. Compute total years using the above conversion table. Which is                                  years = days / 365.
3. Compute total weeks using the above conversion table.Which is                                 weeks = (days – (year *365))/7
4. Compute remaining days using                                                                                               days = days – ((years*365) + (weeks*7)).
”’
#Let us now code the solution
print(“\n\t\t\t https://learnpythonforcbse.wordpress.com/”)

#Read total number of days from user
print(“Enter days: “)
days=int(input())
years = (days / 365) #Ignoring leap year
weeks = (days % 365) / 7
days = ((years * 365) + (weeks * 7)) – days

print(“YEARS: “, years)
print(“WEEKS: “, weeks)
print(“DAYS : “, days)
print(“\n\t\t\t https://learnpythonforcbse.wordpress.com/”)

OUTPUT

prog6