DEV Community

Hasan Sajedi
Hasan Sajedi

Posted on

3 2

Display calendar with python

Python has a built-in function, 'calendar' to work with date related tasks.
You will learn to display the calendar of a given date with below example.


import calendar

yy = 2018
mm = 8

print(calendar.month(yy, mm))
Enter fullscreen mode Exit fullscreen mode

In the program top, we import the calendar module. The built-in function month() inside the module takes in the year and the month and displays the calendar for that month of the year.

Output:

    August 2018
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
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay