Mar-06-2019, 07:49 AM
1. you don't need self in calc_easter(). It's not a class attribute. Thus you don't need to pass date as first argument when call it.
2. when you pass date you pass just generic datetime.date object (i.e. not an instance) and when you print date.month it's just the attribute month of that date object.
2. when you pass date you pass just generic datetime.date object (i.e. not an instance) and when you print date.month it's just the attribute month of that date object.
from datetime import date def calc_easter(year): "Returns Easter as a date object." a = year % 19 b = year // 100 c = year % 100 d = (19 * a + b - b // 4 - ((b - (b + 8) // 25 + 1) // 3) + 15) % 30 e = (32 + 2 * (b % 4) + 2 * (c // 4) - d - (c % 4)) % 7 f = d + e - 7 * ((a + 11 * d + 22 * e) // 451) + 114 month = f // 31 day = f % 31 + 1 return date(year, month, day) start_interval = 1950 end_interval = 2042 for year in range(start_interval, end_interval): easter = calc_easter(year=year) if easter.month == 4 and easter.day == 21: print(easter.strftime('%Y-%m-%d'))
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs