Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
