Mar-05-2019, 08:22 AM
Hi all.
The following code computes the Easter dates in a given interval. My goal is to print out only the ones with a given string, i.e.
Thanks in advance.
The following code computes the Easter dates in a given interval. My goal is to print out only the ones with a given string, i.e.
04-21
, like the actual year Easter date. It should be found (1957,2019,2030,2041).Thanks in advance.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# ---------- easter.py --------------- from datetime import date def calc_easter( self , 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 = 2050 r = range (start_interval, end_interval + 1 ) for n in r: print (calc_easter(date, n)) # ------------------------------ |
Output:1950-04-09
1951-03-25
1952-04-13
1953-04-05
1954-04-18
1955-04-10
1956-04-01
1957-04-21
1958-04-06
1959-03-29
1960-04-17
1961-04-02
1962-04-22
1963-04-14
1964-03-29
1965-04-18
1966-04-10
1967-03-26
1968-04-14
1969-04-06
1970-03-29
1971-04-11
1972-04-02
1973-04-22
1974-04-14
1975-03-30
1976-04-18
1977-04-10
1978-03-26
1979-04-15
1980-04-06
1981-04-19
1982-04-11
1983-04-03
1984-04-22
1985-04-07
1986-03-30
1987-04-19
1988-04-03
1989-03-26
1990-04-15
1991-03-31
1992-04-19
1993-04-11
1994-04-03
1995-04-16
1996-04-07
1997-03-30
1998-04-12
1999-04-04
2000-04-23
2001-04-15
2002-03-31
2003-04-20
2004-04-11
2005-03-27
2006-04-16
2007-04-08
2008-03-23
2009-04-12
2010-04-04
2011-04-24
2012-04-08
2013-03-31
2014-04-20
2015-04-05
2016-03-27
2017-04-16
2018-04-01
2019-04-21
2020-04-12
2021-04-04
2022-04-17
2023-04-09
2024-03-31
2025-04-20
2026-04-05
2027-03-28
2028-04-16
2029-04-01
2030-04-21
2031-04-13
2032-03-28
2033-04-17
2034-04-09
2035-03-25
2036-04-13
2037-04-05
2038-04-25
2039-04-10
2040-04-01
2041-04-21
2042-04-06
2043-03-29
2044-04-17
2045-04-09
2046-03-25
2047-04-14
2048-04-05
2049-04-18
2050-04-10