In this article, we show you how to write a Python program to display the monthly calendar with an example.
Python Calendar Example
This Python calendar example accept year and month as input variables and using those values we are going to display the monthly calendar
# Python Calendar Example # import calendar module import calendar # ask of month and year year = int(input("Please Enter the year Number: ")) month = int(input("Please Enter the month Number: ")) # Displaying the Python calendar print(calendar.month(year, month))
Within this Python calendar example program, First, we are importing the calendar library provided by the Python programming language. The group of function present in this library can help you to perform many operations on the calendar
Next, we are asking the users to enter Year and Month number using the following statements. To make sure that, they are entering the integer values we used the typecast here.
year = int(input("Please Enter the year Number: ")) month = int(input("Please Enter the month Number: "))
The following statement in python calendar example program display the monthly calendar (Here, February 2016)
From the above statement, you can observe that we calling the month function present in the python calendar library. This function accepts two parameters (i.e., Year and Month).