Python Forum
Printing Easter date occurrences
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Printing Easter date occurrences
#5
My last trial! Please, may I have help? Thank you
# ---------- ea2.py ---------------
# https://docs.python.org/2/library/datetime.html
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= 1960

r = range(start_interval, end_interval+1)
for n in r:
	s=calc_easter(date, n)
	print(date.month)  # my intention is to extract the month number (3 or 4),
	                   # same story for the day
                       # and then if condition will solve the matter
# -------- OUTPUT ----------
#     Where is my fault?
# -------------------------- 
#C:\Training>python ea2.py
#<attribute 'month' of 'datetime.date' objects>
#<attribute 'month' of 'datetime.date' objects>
#<attribute 'month' of 'datetime.date' objects>
#<attribute 'month' of 'datetime.date' objects>
#<attribute 'month' of 'datetime.date' objects>
#<attribute 'month' of 'datetime.date' objects>
#<attribute 'month' of 'datetime.date' objects>
#<attribute 'month' of 'datetime.date' objects>
#<attribute 'month' of 'datetime.date' objects>
#<attribute 'month' of 'datetime.date' objects>
#<attribute 'month' of 'datetime.date' objects>
# ---------------------------------------------
Reply


Messages In This Thread
Printing Easter date occurrences - by samsonite - Mar-05-2019, 08:22 AM
RE: Printing Easter date occurrences - by samsonite - Mar-05-2019, 04:38 PM
RE: Printing Easter date occurrences - by woooee - Mar-05-2019, 05:38 PM
RE: Printing Easter date occurrences - by samsonite - Mar-05-2019, 05:54 PM
RE: Printing Easter date occurrences - by samsonite - Mar-06-2019, 06:39 AM
RE: Printing Easter date occurrences - by buran - Mar-06-2019, 07:49 AM
RE: Printing Easter date occurrences - by samsonite - Mar-06-2019, 09:41 AM
RE: Printing Easter date occurrences - by buran - Mar-06-2019, 10:05 AM
RE: Printing Easter date occurrences - by samsonite - Mar-06-2019, 11:49 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Compare current date on calendar with date format file name Fioravanti 1 291 Mar-26-2024, 08:23 AM
Last Post: Pedroski55
  Python date format changes to date & time 1418 4 678 Jan-20-2024, 04:45 AM
Last Post: 1418
  Date format and past date check function Turtle 5 4,349 Oct-22-2021, 09:45 PM
Last Post: deanhystad
  How to add previous date infront of every unique customer id's invoice date ur_enegmatic 1 2,272 Feb-06-2021, 10:48 PM
Last Post: eddywinch82
  Count number of occurrences of list items in list of tuples t4keheart 1 2,408 Nov-03-2020, 05:37 AM
Last Post: deanhystad
  Count & Sort occurrences of text in a file oradba4u 7 3,138 Sep-06-2020, 03:23 PM
Last Post: oradba4u
  How to add date and years(integer) to get a date NG0824 4 2,914 Sep-03-2020, 02:25 PM
Last Post: NG0824
  Counting number of occurrences of a single digit in a list python_newbie09 12 5,641 Aug-12-2019, 01:31 PM
Last Post: perfringo
  Occurrences using FOR and IF cycle P86 2 2,548 Jul-29-2019, 04:37 PM
Last Post: ThomasL
  Substracting today's date from a date in column of dates to get an integer value firebird 1 2,152 Jul-04-2019, 06:54 PM
Last Post: Axel_Erfurt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020