Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

3. You can gain power by making others feel important.

Answered: 1 week ago

Question

Write down the circumstances in which you led.

Answered: 1 week ago