Question
Please start with the following template Write in python. def display_table(dow, num_days): '''Display a calendar table''' assert(type(num_days) == type(dow) == type(0)) assert(0
Please start with the following template
Write in python.
def display_table(dow, num_days):
'''Display a calendar table'''
assert(type(num_days) == type(dow) == type(0))
assert(0 <= dow <= 6)
assert(28 <= num_days <= 31)
# Display a nice table header
print(" Su Mo Tu We Th Fr Sa")
# Indent for the first day of the week
for indent in range(dow):
print(" ", end='')
# Display the days of the month
for dom in range(1, num_days + 1):
print(repr(dom).rjust(4), end='')
dow += 1
# Newline after Saturdays
if dow % 7 == 0:
print("") # newline
# We must end with a newline
if dow % 7 != 0:
print("") # newline
# Output
display_table(1, 31)
When the program prompts the user for a month, only the values 1 through 12 are accepted. Any other input will yield a re-prompt:
Enter a month number: 13 Month must be between 1 and 12. Enter a month number: banana Month must be an integer. Enter a month number: 1
The same is true with years; the user input must be greater than 1752:
Enter year: 90 Year must be 1753 or later. Enter year: 1990
Size of the Month
Your program must know the number of days in a given month. This includes February, which is 28 or 29 days depending on whether it is a leap year. In other words, it must take leap years into account.
First day of the Month
Your program must know the day of the week for the 1st of a given month. This must work for any month in any year from 1753 onward. We start with that year because the Gregorian calendar (the calendar we all use today) began on the 14th of September, 1752.
To accomplish this feat, your program must tabulate the number of days between January 1, 1753 and the 1st of the month that you will be displaying. Note that January 1, 1753 was a Monday.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started