Python Tutorial (33) – Example: Generating a calendar

Time: Column:Python views:272

Python Code to Generate a Calendar for September 2024

The following Python code is updated to generate and display a calendar for September 2024, including the specific date September 12, 2024.

Example: Calendar for September 2024

# Import the calendar module
import calendar

# Set the specific year and month
yy = 2024
mm = 9

# Display the calendar for September 2024
print(calendar.month(yy, mm))

Example Output:

    September 2024
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

This code generates the calendar for September 2024, where September 12, 2024, falls on a Thursday.