05 Nov PMCA Sunday 12:00 Python Homework 20.11.01.
write a program to ask user about the date(year, month and day), then calculate the day of the year.
Day of the year: 175
- You need consider leap years and non leap years, in order to do easier calculation, you may create a list to contain all the days in each month. If it is a leap year, then mo = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], otherwise, mo = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
- % is getting remainder of the division, so we can use it to calculate the leap year or not
- We need to use for i in range() to get the index of every previous month and add them together or using sum(list) to add number items in the slides of the list.