Program to display calendar in Python

Program to display calendar in Python. It is a basic program for new learner. It is necessary to know for beginners, class 11,12 and B Tech computer science students. In this program we learn about module importing, module functions selection, showing the output and capturing variables. Download source code.

calendar is a system of organizing days. The Gregorian calendar is  international standard and is used almost everywhere in the world for civil purposes.

Program to display calendar

Logic :

Calendar module is a module that comes by default with the Python Interpreter. The module is imported and the variables for the module function is given. The calendar for the month and year is displayed.
Calendar module is imported. The calendar.month(yy,mm) are the function which are printed the calendar of the reswpective month.

Source code :

import calendar  
# Enter the month and year  
yy = int(input("Enter year: "))  
mm = int(input("Enter month: "))  
  
# display the calendar  
print(calendar.month(yy,mm))

Download Source code : For Download Click on the below Button

Step wise Source code Explanation :

Step 1 : calendar named library module is being imported
import calendar
Step 2: The year of the calendar is captured by variable yy.
yy = int(input(“Enter year: “))
Step 3: The month of the calendar is captured by variable mm.
mm = int(input(“Enter month: “))
Step 4: The calendar is printed on the screen.
print(calendar.month(yy,mm))

Output :

Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> 
 RESTART: C:/Users/ARCHIT/AppData/Local/Programs/Python/Python37-32/test1.py 
Enter year: 2022
Enter month: 8
    August 2022
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

>>> 

Output Explanation :

Year is captured.
Enter year: 2022
month is captured.
Enter month: 8
The calendar month is shown

August 2022
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 of Program to display calendar in Python :

The calendar is shown for the year and month. In this program we learn about module importing, module functions selection, showing the output and capturing variables. The calendar is shown for the year and month. Program runs perfectly.

Thank you for reading and learning from Program to display calendar in Python post. This is necessary to know for beginners, class 11,12 and B Tech computer science students. For more program practice click below links.

Python Programs Archives – CS Study : Basic program are provided.

Computer Science with Python Practical Book Solutions Class 11 Term -2 – CS Study : 11 class Practical program is provided.

Computer Science Practical file for class 12 Term-2 – CS Study : 12 class Practical program is provided.

Leave a Comment

Your email address will not be published.