Python Program - Display Calendar
here's a Python program that displays a calendar for a given month and year:
refer to:theitroad.comimport calendar # get the month and year from user year = int(input("Enter the year: ")) month = int(input("Enter the month: ")) # print the calendar print(calendar.month(year, month))
In this program, we first import the calendar
module using the import
keyword.
We then use the input()
function to get the month and year from the user, and store them in the variables year
and month
respectively.
Finally, we use the calendar.month()
function to print out a calendar for the specified month and year. The calendar.month()
function takes two arguments - the year and the month - and returns a string containing the calendar for that month. We use the print()
function to print out the calendar on the console.