

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Print a Calendar in Python
In this tutorial, we are going to learn how to print the calendar of month and year using the calendar module of Python. It's a straightforward thing in Python. We need year and month numbers. That's it.
Let's see how to print a year calendar. Follow the below steps to print the year calendar.
Import the calendar module.
Initialize the year number.
Print the calendar using calendar.calendar(year) class.
Example
See the below code.
# importing the calendar module import calendar # initializing the year year = 2020 # printing the calendar print(calendar.calendar(year))
Output
If you run the above code, you will get the following output.
2020 January February March Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su 1 2 3 4 5 1 2 1 6 7 8 9 10 11 12 3 4 5 6 7 8 9 2 3 4 5 6 7 8 13 14 15 16 17 18 19 10 11 12 13 14 15 16 9 10 11 12 13 14 15 20 21 22 23 24 25 26 17 18 19 20 21 22 23 16 17 18 19 20 21 22 27 28 29 30 31 24 25 26 27 28 29 23 24 25 26 27 28 29 30 31 April May June Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su 1 2 3 4 5 1 2 3 1 2 3 4 5 6 7 6 7 8 9 10 11 12 4 5 6 7 8 9 10 8 9 10 11 12 13 14 13 14 15 16 17 18 19 11 12 13 14 15 16 17 15 16 17 18 19 20 21 20 21 22 23 24 25 26 18 19 20 21 22 23 24 22 23 24 25 26 27 28 27 28 29 30 25 26 27 28 29 30 31 29 30 July August September Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su 1 2 3 4 5 1 2 1 2 3 4 5 6 6 7 8 9 10 11 12 3 4 5 6 7 8 9 7 8 9 10 11 12 13 13 14 15 16 17 18 19 10 11 12 13 14 15 16 14 15 16 17 18 19 20 20 21 22 23 24 25 26 17 18 19 20 21 22 23 20 21 22 23 24 25 26 27 28 29 30 31 24 25 26 27 28 29 30 27 28 29 30 31 October November December Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su 1 2 3 4 1 1 2 3 4 5 6 5 6 7 8 9 10 11 2 3 4 5 6 7 8 7 8 9 10 11 12 13 12 13 14 15 16 17 18 9 10 11 12 13 14 15 14 15 16 17 18 19 20 19 20 21 22 23 24 25 16 17 18 19 20 21 22 21 22 23 24 25 26 27 26 27 28 29 30 31 23 24 25 26 27 28 29 28 29 30 31 30
Let's see how to print a month calendar. Follow the below steps to print the month calendar.
Import the calendar module.
Initialize the year and month number.
Print the calendar using calendar.month(year, month) class.
Example
See the below code.
# importing the calendar module import calendar # initializing the year and month year = 2020 month = 1 # printing the calendar print(calendar.month(year, month))
Output
If you execute the above program, you will get the following result.
January 2020 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
Conclusion
If you have any doubts in the tutorial, mention them in the comment section.
- Related Questions & Answers
- How to print calendar for a month in Python?
- Print calendar for a given year in C++
- Calendar in python
- Calendar Functions in Python - ( calendar(), month(), isleap()?)
- How to print a calendar for the given month and year in Python?
- Calendar function in Python
- Calendar in Python Program
- Getting calendar for a month in Python
- Calendar Functions in Python | Set 1( calendar(), month(), isleap()…)
- Explain calendar module in python?
- What is calendar module in python?
- Calendar Functions in Python -(monthrange(), prcal(), weekday()?)
- The calendar Module in Python
- How to Display Calendar using Python?
- How to print a one-month calendar of user choice using for loop in C?