Task: Write a Python Program to output the required Calendar. This Python programming tutorial will explain how to use calendar module to show a required calendar.
What is the calendar Module in Python?
The Python’s calendar module permits you to develop and display calendars. The calendar module provides additional useful functions related to the calendar also. By default, it provides a calendar that has Monday as the first day of the week, and Sunday as the last according to the European convention.
The Source code of Python script to show a Calendar
# Write a Python program to output # a required calnendar on the basis # of input month and year. # author : www.EasyCodebook.com # for Perfect Programming Tutorials # *** Start of program *** # import the calendar module import calendar # Get the month and year from the user calendar_year = int(input("Enter the year for calendar: ")) calendar_month = int(input("Enter the month for calendar: ")) # output the required calendar print(calendar.month(calendar_year,calendar_month))
The display of required calendar
Enter the year for calendar: 2019
Enter the month for calendar: 8
August 2019 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31