Python program that uses the built-in calendar module to display a calendar for a given year:

Created with Sketch.

python program that uses the built-in calendar module to display a calendar for a given year:

import calendar

year = int(input("Enter a year: "))
print(calendar.calendar(year))

The calendar.calendar() function takes a single argument, the year for which to display the calendar, and returns a string representation of the calendar for that year. The input() function is used to prompt the user to enter a year, and the resulting value is converted to an integer using the int() function.

You could also use calendar.prcal(year) or calendar.prmonth(year, month, w=2, l=1) to display the calendar in a more readable format.

Leave a Reply

Your email address will not be published. Required fields are marked *