The Calendar Module
The calendar module provides calendar-related functions, and also includes the functions to print a text calendar for a given month or year.
To import a calendar module
Functions/methods of calendar module:
The following are some of the functions/methods of Calendar module.
1. calendar.firstweekday ( )
This returns the current setting for the weekday that starts each week. By default, when calendar is first imported, this is 0, meaning Monday.
|>>> calendar.firstweekday( )
This returns true if the given year is a leap year; otherwise, it returns false.
>>> year=int(input(“Enter year: “))
Enter year: 1989
This returns the total number of leap days in the years within range(y1,y2).
This returns a multi-line string with a calendar for month of year, one line per week plus two header lines. w is the width in characters of each date; each line has length 7*w+6. l is the number of lines for each week.
This returns two integers. The first one is the code of the weekday for the first day of the month month in year year; the second one is the number of days in the month. Weekday codes are 0 (Monday) to 6 (Sunday); month numbers are 1 to 12.
It is similar to as print calendar.calendar(year,w,l,c).
It is similar to calendar.month(year,month,w,l). Prints specific month.
This returns the weekday code for the given date. Weekday codes are 0 (Monday) to 6 (Sunday); month numbers are 1 (January) to 12 (December).
1. A python program to print a HTML calendar.
2. A python program to print the names of the months.
3.A python program to print the weekdays.
4.A Python program to display calendar of particular month of the year.