In this article, I’ll show you those two lines of Python code, using which you can print calendar of any year.
Required Package
The pre-requisite to generate calendar is to import the required package named calendar as shown below:
from calendar import *
Generate Calendar
Now to generate a calendar, we need to call constructor and pass in four parameters as shown below:
print(calendar(2018,2,1,4))
Here,
- 2018 is the year for which calendar will be printed
 - 2 signifies width of each character
 - 1 signifies number of lines per week
 - 4 signifies column separation value
 
You can adjust the last three parameters for better spacing in between the text.
Output
This is how the calendar looks like:
I hope you enjoyed generating a calendar of your choice. Make sure to check out my recording explaining each and every parameter discussed in this article:

Comments
Post a Comment