Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Ask the user to type in a year ( < 2 0 0 0 ) and a month ( 1 - 1 2 ) .
Ask the user to type in a year and a month Your program should print out that month calendar.
reuse the code above if applicable.
can you help i want contiue my code is stop calculating the correct data after
# use list or tuple for the given data
monthname January "February", "March", "April", "May", "June",
"July", "August", "September", "Octber","November", "December"
weekday Sun "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
monthday
# Given Jan. falls on a Sat.
yyyy
offset
# Code here
def isleapyearyear:
Checks if it's a leap year."""
return year and year or year
def daysinmonthyear month:
Gives the number of days in a month."""
if month :
return if isleapyearyear else
elif month in :
return
else:
return
def weekdayoffirstdayyear month:
Returns the weekday Monday, Sunday of the first day of the month."""
dayssince
for y in rangeyear:
dayssince if isleapyeary else
for m in range month:
dayssince daysinmonthyear m
return dayssince # because December is a Saturday
def printmonthcalendaryear month:
Prints the calendar of a given month."""
# Validate input
if year :
printPlease enter a year prior to
return
if month or month :
printPlease enter a valid month
return
if year and month :
firstdayofdecember weekdayoffirstdayyear month
if firstdayofdecember : # Saturday
daystoadd firstdayofdecember
month
if month :
month
year
printmonthcalendaryear month
return
printfmonthnamemonth year
# Print the calendar
print Su Mo Tu We Th Fr Sa
firstday weekdayoffirstdayyear month
for in rangefirstday:
print end
for day in range daysinmonthyear month:
printfday: end
if firstday day or day daysinmonthyear month:
print
# Ask for user input
year intinputEnter a year :
month intinputEnter a month :
# Print the calendar
printmonthcalendaryear month
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