ED) viii)
Calendar Module
Beyond the Time module, the Calendar module can produce some interesting results
when executed within your code. It does far more than simply display the date in the
Time module-like format, you can actually call up a wall calendar type display.
WORKING WITH DATES
‘The Calendar module is built into Python 3. However,
‘calendar as a Windows administrator, or sudo pip
For some reason it's not installed you can add it using pip install
3 calendar for Linux and macOs.
BERD [2urch Python 3and enter: import calendarto [ERTS There are numerous functions within the Calendar
call up the module endits inherent Functions, Once ‘module that may be of interest to you when
it’s Loaded into memory, start by entering: Forming your own code. For example, you can display the number of
leap years between twa spec years:
ype Scooprdahtts Seredite® or *Licanan()" for sore infornat
2 esert calender F
letra. 0)
«
6.3.6 20176536] on Linux
‘Type “copyright", seredits” or “Iicense()" for more information
You can see that the days of September 2019 are You could even fashion that particular example into
displayed in a wall calendar fashion, Naturally you piece of working, user interactive Python code:
‘can change the 2019, 9 part ofthe second line to any year and
month you want, a birthday For example (1873, 6). The First line
configures TextCalendar to start its weeks on a Sunday; you can opt
For Monday if you prefer.
yon 83shal sex
rasan “cee for sre Snermeton
SS cater sn)
iYou can also create a program that wil display all
the days, weeks and months within a given year:
‘We're sure you'll agree that's quite a handy bit of code to have
tohand.
Interestingly we can also list the number of days in a
BARD by using a snp: fr oon
import calendar