Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Python Tutorial
  • Interview Questions
  • Python Quiz
  • Python Glossary
  • Python Projects
  • Practice Python
  • Data Science With Python
  • Python Web Dev
  • DSA with Python
  • Python OOPs
Open In App
Next Article:
Calendar Functions in Python | Set 2(monthrange(), prcal(), weekday()...)
Next article icon

Calendar in Python

Last Updated : 03 May, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

Python 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 Example

Input: yy = 2023 mm = 4

Output:

Calendar in Python
Calendar of April 2023

Displaying a Calendar for a Month in Python

In the program below, we import the Python calendar module. The built-in function month() inside the module takes in the year and the month and displays the calendar for that month of the year.

Python3
# import module import calendar  yy = 2023 mm = 4  # display the calendar print(calendar.month(yy, mm)) 

Output:

Displaying a Calendar for a Month in Python
Calendar of April 2023

OR, you can directly run from the command line (CMD in Windows or TERMINAL in Linux ) for displaying a month of a year. Just write the following command:

python -m calendar 2023 4

Output:

Calendar of April 2023
Calendar of April 2023

Displaying Calendar of a given Year in Python

In the program below, we import the calendar module. The built-in Python calendar() function inside the module takes in the year and displays the calendar for that year.

Python3
# import module import calendar  yy = 2017  # display the calendar print(calendar.calendar(yy)) 

Output:

Displaying Calendar of a given Year in Python
Calendar of 2023

OR, you can directly run from the command line (CMD in Windows or TERMINAL in Linux ) for displaying a year:

python -m calendar 2023

Output:

Calendar of 2023
Calendar of 2023

Next Article
Calendar Functions in Python | Set 2(monthrange(), prcal(), weekday()...)

A

ajay0007
Improve
Article Tags :
  • Technical Scripter
  • Python
  • Python Calander-module
Practice Tags :
  • python

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 Calendar

    • Calendar in Python
      Python 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 Calendar

    • How to Get Current Date and Time using Python
      In 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 ModuleI
      6 min read

    • Working With Dates in Python
      In 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 day
      In 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 Python
      In 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 Functions

    • Python calendar module : iterweekdays() method
      Calendar 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() method
      Calendar 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() method
      Calendar 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() method
      Calendar 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() method
      Calendar 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() method
      Calendar 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() method
      Calendar 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() method
      Calendar 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() method
      Calendar 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() method
      Calendar 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 Functions

    • Python calendar module : prmonth() method
      The 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() method
      Calendar 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() method
      Calendar 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 Functions

    • Python calendar module : HTMLCalendar formatyear() method
      Calendar 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() method
      Calendar 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 Functions

    • Python calendar module | firstweekday() method
      Calendar 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() method
      Calendar 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() method
      Calendar 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

geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences