Write a Python program that generates and prints a calendar for a specific month in a given year. You should utilize Python’s built-in calendar
module to simplify the calendar-related operations.
print_month(year, month)
that takes the year
and month
as arguments (integers) and prints a calendar for the specified month. The function performs this by calling the function print_month_title(year, month)
and print_month_body(year, month)
respectively.print_month_title(year, month)
to print the title of the calendar, displaying the month name and year. This function also prints the header separator and the days of the week (see example). tip: use the calendar.month_name
object to find the month name based on the month number.print_month_body(year, month)
to print the body of the calendar, which includes the days of the month with proper formatting. For this the calendar module can also be used!An example output is given below:
June 1997 ----------------------------- Mon Tue Wed Thu Fri Sat Sun 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
print_month_title(year, month)
and print_month_body(year, month)
, the calendar module in Python can be used to easily calculate the required calendar data.