Date of Easter for the Years 1982-2048
Python Programming: Chapter 7, Exercise 9.
Most of this is from ReexamPracticeQuestionSolutions.pptx (or in my case, .odp). You can download it at: http://www.csee.usf.edu/~rtindell/courses/Python/Solutions/
##from: ReexamPracticeQuestionSolutions.pptx '''Ex 9. A formula for computing the date of Easter in the years 1982-2048, inclusive,is as follows: Let a = year % 19, b = year%4, c = year%7, d = (19*a + 24)%30, and e = (2*b+4*c+6*d+5)%7. The date of Easter is (d+e) days after March 22 (which could be in April). Write a program that inputs a year, verifies that it is in the proper range, and then prints the date of Easter that year. Check dates at: http://www.assa.org.au/edm.html''' def main(): year =input("Enter a year between 1982 and 2048: ") if year < 1982 or year > 2048: print("Illegal date") else: a = year%19 b = year%4 c = year%7 d = (19*a+24)%30 e = (2*b+4*c+6*d+5)%7 days_after = d+e days = 22+days_after print "In year ",year,", Easter falls on", if days <= 31: print"March " ,str(days) else: print"April " , str(days-31) main()
- Posted in: Exercises ♦ Python ♦ Python Programming
- Tagged: Chapter 7, Date of Easter, Easter, ex 9, Exercises, language python, Python, Python Programming, python tutorial, Zelle