► Python program to print the calendar of a given month and year


Steps followed:
1. import calendar module
2. get year as input from user and store it in y variable
3. get month as input from user and store it in m variable
4. use calendar module to display calendar as per user input


Program

#Python program to print the calendar of a given month and year

# import calendar module
import calendar

#get year as input from user and store it in y variable
y = int(input("input the calendar year :"))

#get month as input from user and store it in m variable
m = int(input("input the calendar month :"))

#use calendar module to display calendar as per user input 
print(calendar.month(y,m))
 


Output

input the calendar year :2021
input the calendar month :8
    August 2021
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

 

input the calendar year :2020
input the calendar month :10
    October 2020
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





Also Read: