Python | Calendar Module Last Updated : 17 Nov, 2023 Comments Improve Suggest changes Like Article Like Report 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 PythonThe 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 YearThe 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.calendarThe 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: FunctionDescriptioniterweekdays()Returns an iterator for the weekday numbers that will be used for one weekitermonthdates()Returns an iterator for the month (1–12) in the yearitermonthdays()Returns an iterator of a specified month and a yearitermonthdays2()This method is used to get an iterator for the month in the year similar to itermonthdates(). Days returned will be tuples consisting of a day of the month number and a week day number.itermonthdays3()Returns an iterator for the month in the year similar to itermonthdates(), but not restricted by the datetime.date range. Days returned will be tuples consisting of a year, a month and a day of the month numbers.itermonthdays4()Returns an iterator for the month in the year similar to itermonthdates(), but not restricted by the datetime.date range. Days returned will be tuples consisting of a year, a month, a day of the month, and a day of the week numbers.monthdatescalendar()Used to get a list of the weeks in the month of the year as full weeksmonthdays2calendar()Used to get a list of the weeks in the month of the year as full weeksmonthdayscalendarUsed to get a list of the weeks in the month of the year as full weeksyeardatescalendar()Used to get a list of the weeks in the month of the year as full weeksyeardays2calendar()Used to get the data for specified year. Entries in the week lists are tuples of day numbers and weekday numbersyeardayscalendar()Used to get the data for specified year. Entries in the week lists are day numbersclass calendar.TextCalendarTextCalendar 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. FunctionDescriptionformatmonth()This method is used to get the month’s calendar in a multi-line stringprmonth()This method is used to print a month’s calendar as returned by formatmonth()formatyear()This method is used to get m-column calendar for an entire year as a multi-line stringpryear()This method is used to print the calendar for an entire year as returned by formatmonth()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. FunctionDescriptionformatmonth()This method is used to get the month’s calendar as an HTML tableformatyear()This method is used to get a year’s calendar as an HTML table.formatyearpage()This method is used to get the year’s calendar as a complete HTML pageSimple TextCalendar classFor simple text calendars calendar module provides the following functions: FunctionDescriptionsetfirstweekday()This method sets the day start number of the weekfirstweekday()This method returns the first weekday number. By default 0 (Monday)isleap()This method checks if the year mentioned in the argument is leap or notleapdays()This method returns the number of leap days between the specified years in argumentsweekday()This method returns the weekday number(0 is Monday) of the date specified in its argumentsweekheader()Returns a header containing abbreviated weekday namesmonthrange()The function returns two integers, first, the starting day number of the week(0 as monday), second, the number of days in the monthmonthcalendar()Returns a matrix representing a month’s calendar. Each row represents a week; days outside of the month are represented by zerosprmonth()The function also prints the month of a specific year but there is no need of “print” operation to execute thismonth()The function prints the month of a specific year mentioned in argumentsprcal()The function also prints the calendar of a specific year but there is no need of “print” operation to execute thiscalendar()The function displays the calendar for the given year. Comment More infoAdvertise with us Next Article Calendar in Python abhishek1 Follow Improve Article Tags : Python python-modules python Practice Tags : pythonpython Similar Reads Python | Calendar Module 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 PythonThe calendar module allows us to output calendars like the program and provides additional useful functions related 5 min read Introduction to Python CalendarCalendar in PythonPython has a built-in Python Calendar module to work with date-related tasks. Using the module, we can display a particular month as well as the whole calendar of a year. In this article, we will see how to print a calendar month and year using Python. Calendar in Python ExampleInput: yy = 2023 mm = 2 min read Calendar Functions in Python | Set 2(monthrange(), prcal(), weekday()...)Some of calendar functions are discussed in the Set 1 1. monthrange(year, month) :- This function returns two integers, first, the starting day number of week(0 as monday) , second, the number of days in the month. 2. prcal(year, w, l, c) :- This function also prints the calendar of specific year bu 5 min read Working with Dates in Python CalendarHow to Get Current Date and Time using PythonIn this article, we will cover different methods for getting data and time using the DateTime module and time module in Python.Different ways to get Current Date and Time using PythonCurrent time using DateTime objectGet time using the time moduleGet Current Date and Time Using the Datetime ModuleIn 6 min read Working With Dates in PythonIn this article, we will discuss how to work with dates using python. Python makes dealing with dates and time very easy, all we have to do is import a module named DateTime that comes along with python. It is a more efficient way to work with date without the need of being explicitly programmed. By 4 min read Python program to print current year, month and dayIn this article, the task is to write a Python Program to print the current year, month, and day. Approach: In Python, in order to print the current date consisting of a year, month, and day, it has a module named datetime. From the DateTime module, import date classCreate an object of the date clas 1 min read Formatting Dates in PythonIn different regions of the world, different types of date formats are used and for that reason usually, programming languages provide a number of date formats for the developed to deal with. In Python, it is dealt with by using a liberty called DateTime. It consists of classes and methods that can 5 min read Calendar.Calendar FunctionsPython calendar module : iterweekdays() methodCalendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions. iterweekdays() method return 1 min read Python calendar module | itermonthdates() methodCalendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions. itermonthdates() method retu 2 min read Python calendar module : itermonthdays() methodCalendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions. itermonthdays() method retu 1 min read Python calendar module | itermonthdays2() methodCalendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions. itermonthdays2() method is u 2 min read Python calendar module : monthdatescalendar() methodCalendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions. monthdatescalendar() method 2 min read Python calendar module : monthdays2calendar() methodCalendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions. monthdays2calendar() method 2 min read Python calendar module | monthdayscalendar() methodCalendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions. monthdayscalendar() method i 2 min read Python calendar module : yeardatescalendar() methodCalendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions. yeardatescalendar() method i 3 min read Python calendar module : yeardays2calendar() methodCalendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions. yeardays2calendar() method i 3 min read Python calendar module : yeardayscalendar() methodCalendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions. yeardayscalendar() method i 2 min read Calendar.TextCalendar FunctionsPython calendar module : prmonth() methodThe calendar module allows the output of calendar-like programs and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar is extended indefinitely in both directions. class calendar.Tex 2 min read Python calendar module : formatyear() methodCalendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions. class calendar.TextCalendar( 6 min read Python calendar module : TextCalendar pryear() methodCalendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions. class calendar.TextCalendar( 6 min read Calendar.HTMLCalendar FunctionsPython calendar module : HTMLCalendar formatyear() methodCalendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions. class calendar.HTMLCalendar( 9 min read Python calendar module : HTMLCalendar formatyearpage() methodCalendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions. class calendar.HTMLCalendar( 15+ min read Simple TextCalendar FunctionsPython calendar module | firstweekday() methodCalendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions. In Python, calendar.firstwee 2 min read Python calendar module | isleap() methodCalendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions. In Python, calendar.isleap() 2 min read Python calendar module : leapdays() methodCalendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions. In Python, calendar.leapdays 2 min read Like