Write a Python program that uses the calendar module to display the calendar for a specific month and year.
Example 1:
Input: Month: 5, Year: 2023
Output:
May 2023
Mo Tu We Th Fr Sa Su
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 31
Example 2:
Input: Month: 12, Year: 2025
Output: December 2025 Mo Tu We Th Fr Sa Su 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 31
The calendar module in Python allows you to output calendars, and provides additional useful functions related to the calendar. The month() function gives the calendar for a specified month and year.
import calendar
def display_calendar(year, month):
return calendar.month(year, month)
print(display_calendar(2023, 5))
print(display_calendar(2025, 12))
Unlock AI & Data Science treasures. Log in!