# easter_calculator.py
# This program takes a year as an input, verifies that it is in the proper
# range, and then prints out the date of Easter that year.
# by: Scott Gordon
from datetime import datetime, timedelta
def main():
print("Welcome To the Easter Calculator\n")
print("Choose a year that you want to find the date of easter from 1982-2048")
year = int(input("Please enter the year (yyyy) here: "))
def easter_calc(year):
"""Takes year as input and prints out when Easter was that year."""
a = year % 19
b = year % 4
c = year % 7
d = ((19*a) + 24) % 30
e = (2*b + 4*c + 6*d + 5) % 7
start_date = datetime(year, 3, 22)
format = "%m/%d/%y"
easter = start_date + timedelta(d+e)
if (year >= 1982) and (year <= 2048):
return f"\nThe date of Easter is {easter.strftime(format)}"
else:
return f"\nSorry you must choose a year from 1982 to 2048."
print(easter_calc(year))
if __name__ == "__main__":
main()
Photo by Annie Spratt on Unsplash
Top comments (0)