- Code: Select all
`# Lists and Dictionaries.`

months = {'January': 6, 'February': 2, 'March': 2, 'April': 5, 'May': 0, 'June': 3, 'July': 5, 'August': 8, 'September': 4, 'October': 6, 'November': 2, 'December': 4}

weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]

# Fruitful Functions for Algorithm.

def yearcode(y):

"""Year Code Generator Algorithm"""

y = y % 100

y = y + (y / 4) % 7

return int(round(y))

def monthcode(m):

"""Retrieve Month Number from Month Dictionary"""

return int(months[m])

def daycode(d):

"""Simplify Day Input for Efficiency"""

return d % 7

# Inputs.

dayin = int(input("What Day?"))

monthin = input("What Month?")

yearin = int(input("What Year?"))

# Define Variables for Functions.

yearout = yearcode(yearin)

monthout = monthcode(monthin)

dayout = daycode(dayin)

# Final Add-Up and Output.

result = int((dayout + monthout + yearout) % 7)

print("That date is a", weekdays[result])

The user puts in the date, and it gives the weekday with 100% accuracy. I know this is pointless, there being a calender module in Python. However I wanted to integrate the Domesday Algorithm into Python. This is written in Python 3.