Python Program to Display Calendar

In this example, we will write a program that will display a calendar by taking input year and month from the user. To better understand this example, make sure you have knowledge of the following tutorials:-

Python Program to Display Calendar by taking year and month as input from user

import calendar


yy = int(input("Enter year: "))
mm = int(input("Enter month: "))

print(calendar.month(yy, mm))

The output of the above program is:-

Enter year: 2019
Enter month: 1
January 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

 

Python Program to Display Calendar for the current month

import calendar
from datetime import datetime

today = datetime.today()

print(calendar.month(today.year, today.month))

The output of the above program is:-

  April 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

SHARE Python Program to Display Calendar

You may also like...

Leave a Reply

Your email address will not be published.

Share