Easter Py

Posted by Steve on March 09, 2009
Uncategorized

With Easter (rapidly?) approaching I thought now would be a good time to post some code.

So here’s how you calculate the date of Easter (in python as it happens)

"To Calculate the Date of Easter"
year = input("Which year do you wish to calculate the date of Easter for: ")
a= year % 19
b = year//100
c = year % 100
d = b // 4
e = b % 4
f = (b+8)//25
g = (b-f+1)//3
h = (19*a + b -d -g + 15) % 30
i = c//4
k = c % 4
l = (32+2*e+2*i-h-k) % 7
m = (a + 11*h+22*l)//451
n = (h+l-7*m+114)//31
p = (h+l-7*m+114) % 31
print "Easter is on", (p+1),"/",n,"/",year

The method is from “Practical Astronomy With Your Cacluator” by Peter Duffett-Smith (which I recommend for anyone with an interest in Astronomy). It is based on the fact that Easter Sunday is first Sunday after the 14th day of the lunar month (the nominal full moon) that falls on or after 21 March (nominally the day of the vernal equinox).

I was going to post my code to simulate an Enigma Machine, but I seem to have lost it, if  I do ever find it I’ll put it up.

No comments yet.

Leave a comment

WP_Big_City