Here in this article, we have provided a python source code that displays the calendar of the user entered date.
Prerequisite Python Program to Display Calendar
- Python Input, Output
- Python User-Defined Function
- Python Built-functions
- Python Modules
In Python, we have an in-built module known as
calendar
which can be used to print a proper calendar interface according to the user input.
Steps:
- Import the calendar module
- ask the user to enter month and year.
- Use the calendar.month () method to print the month calendar.
Python Code
import calendar
year = int(input("Enter the Year e.g. 2011: "))
month = int(input("Enter the Month e.g. 12: "))
print(calendar.month(year,month))
Output 1:
Enter the Year e.g. 2011: 2020
Enter the Month e.g. 12: 1
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
Output 2:
Enter the Year e.g. 2011: 2019
Enter the Month e.g. 12: 12
December 2019
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
People are also reading:
- Python Program to find Hash of File
- WAP to convert a lowercase alphabet to uppercase or vice-versa using ASCII code
- Python Program to Merge Mails
- WAP to print given series:1 2 4 8 16 32 64 128
- Python Program to Find the Sum of Natural Numbers
- How to Find Square Root in Python?
- WAP in C++ & Python to transpose a Matrix
- Rectangle & Pyramids Pattern in C++
- C Program to Convert Feet into Inches
- WAP in C++ and python to check whether the number is even or odd
Leave a Comment on this Post