In [13]:
def is_leap_year(year):
return (year % 4 == 0 and year % 100 != 0) or year % 400 == 0
def calendar(month, day):
common_year = [31, 28 + int(is_leap_year(2016)), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
date_list = ["thurs", "fri", "satur", "sun","mon","tues","wednes"]
changed_day = {}
for i in range(7):
changed_day[i] = date_list[i] + "day"
temp_day = 0
if is_leap_year(2016):
for i in range(month-1):
temp_day += common_year[i]
else:
for i in range(month-1):
temp_day += common_year[i]
temp_day += day
return changed_day[temp_day % 7]
calendar( 5, 10)
Out[13]: