Python defines an inbuilt module calendar that handles operations related to the calendar. In this article, we will see the Python Program to Display Calendar.
Calendar Module in Python
The calendar module allows us to output calendars like the program and provides additional useful functions related to the calendar. Functions and classes defined in the calendar module use an idealized calendar, the current Gregorian calendar is extended indefinitely in both directions. By default, these calendars have Monday as the first day of the week, and Sunday as the last (the European convention).
Display the Python Calendar of a given Month
The code uses Python’s calendar
module to print a calendar for the specified year (yy) and month (mm). In this case, it prints the calendar for November 2017. Python Program to Display Calendar
Python3
import calendar
yy = 2017
mm = 11
print (calendar.month(yy, mm))
|
Output:

Display the Python calendar of the given Year
The code you provided uses Python’s calendar
module to print a calendar for the year 2018.
Python3
import calendar
print ( "The calendar of year 2018 is : " )
print (calendar.calendar( 2018 ))
|
Output:

class calendar.calendar
The calendar class creates a calendar object. A calendar object provides several methods that can be used for preparing the calendar data for formatting. This class doesn’t do any formatting itself. This is the job of subclasses. The calendar class allows the calculations for various tasks based on date, month, and year and provides the following methods:
class calendar.TextCalendar
TextCalendar class can be used to generate plain text calendars. TextCalendar class in Python allows you to edit the calendar and use it as per your requirement.
class calendar.HTMLCalendar :
HTMLCalendar class can be used to generate HTML calendars. HTMLCalendar class in Python allows you to edit the calendar and use as per your requirement.
Simple TextCalendar class
For simple text calendars calendar module provides the following functions:
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
17 Nov, 2023
Like Article
Save Article