To display calendar in python, you have to ask from user to enter year and month to print the calendar of that year and month as shown here in the program given below.
Following python program ask from user to enter year and month to display calendar:
# Python Program - Display Calendar import calendar print("------Calendar Program in Python------\n"); print("Enter 'x' for exit."); y = input("Enter Year: "); if y == 'x': exit(); else: m = input("Enter month: "); yy = int(y); mm = int(m); print("\n",calendar.month(yy,mm));
Using the above program, you can find the calendar of any month from any years, for example, if you will provide 2015 as year and 3 as month, then you will see the calendar of march 2015 with all the date and day.
Here is the sample run of the above Python program illustrating how to display or print calendar of given year and month:
Now enter a year say 2018 and then a month say 3 (3rd month of the year is march) and then press enter key to see the march's calendar of the year 2018 as shown here in below screenshot:
Below is the screenshot of same program with run on python shell: