Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Does this print a calendar?
#Sun = 0 Determination_of_the_day_of_the_week
def dayofweek(y, m, d):
t = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4];
if( m < 3 ):
y -= 1
return (y + y//4 - y//100 + y//400 + t[m-1] + d) % 7
def leap(year):
return (year % 4 == 0 and (year % 100 != 0 or year % 400 == 0))
def daysinmonth(year, month):
dm = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
d = dm[month-1]
if(month==2 and leap(year)):
d = 29
return d
def printmonth(y, m):
print("Mon Tue Wed Thu Fri Sat Sun")
bs = (dayofweek(y, m, 1)+6)% 7
print(' '*4*bs, end='')
dm = daysinmonth(y, m)
for x in range(1, 1+dm):
ender = ((bs+x)%7) and x!=dm
print('{:3}'.format(x), end=' ' if ender else '\n')
for m in range(1, 13):
printmonth(2021, m)
Be the first to answer this question.