In this article we will show you, How write a Python program to display the monthly calendar with example.
Python Calendar Example
This example will accept year and month as input variables and using those values we are going to display the monthly calendar
# 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))
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 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 type cast here.
year = int(input("Please Enter the year Number: ")) month = int(input("Please Enter the month Number: "))
Following statement will display the monthly calendar (Here, February 2016)
From the above statement you can observe that, we calling the month function present in calendar library and this function accepts two parameters (i.e., Year and Month).
Thank You for visiting Our Blog