codescracker


python

Python Program to Display Calendar



« Previous Program Next Program »


Display Calendar in Python

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.

Python Programming Code to Display Calendar

Following python program ask from user to enter year and month to display calendar:

# Python Program - Display Calendar
		
import calendar
while True:
	print("Enter 'x' for exit.")
	y = input("Enter Year: ")
	m = input("Enter month: ")
	if y == 'x':
		break
	else:
		yy = int(y)
		mm = int(m)
		print("\n",calendar.month(yy,mm))

Here is the sample run of the above Python program illustrating how to display or print calendar of given year and month:

python display calendar

« Previous Program Next Program »




Tools
Calculator

Quick Links
Signup - Login - Give Online Test