In this program, you’ll learn how to Display Calendar using Python function.
Python has a built-in function, a calendar to work with a date associated duties. you will learn to Display Calendar of a given date in this example.
To properly understand this example to Display Calendar in Python, you should have the knowledge of following Python programming topics:
- Python Modules
- Python Programming Built-in Functions
In the program below, we import the 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.
Program to display the calendar of given month of the year using Python function
# import module import calendar yy = 2017 mm = 10 # To ask month and year from the user # yy = int(input("Enter year: ")) # mm = int(input("Enter month: ")) # display the calendar print(calendar.month(yy, mm))
Output
October 2017 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
Note: You can change yy
and mm
according to you here we have taken Month: October (10) and Year: 2017
Related Program:
- Program to Find LCM in Python
- Program to Find HCF or GCD in Python
- Program to find the area of Triangle in Python
- Program to Solve Quadratic Equation in Python
Ask your questions and clarify your/others doubts on How to Display Calendar in Python by commenting. Python Documentation