{"id":26035,"date":"2021-12-14T08:43:08","date_gmt":"2021-12-14T03:13:08","guid":{"rendered":"https:\/\/python-programs.com\/?p=26035"},"modified":"2021-12-14T08:43:08","modified_gmt":"2021-12-14T03:13:08","slug":"python-program-for-calendar-leapdays-method-with-examples","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-calendar-leapdays-method-with-examples\/","title":{"rendered":"Python Program for calendar leapdays() Method with Examples"},"content":{"rendered":"

Calendar Module:<\/strong><\/p>\n

The calendar module allows you to output calendars like a program and includes extra calendar-related operations. Calendar module functions and classes make use of an idealized calendar, the current Gregorian calendar extended in both directions indefinitely.<\/p>\n

leapdays() Method:<\/strong><\/p>\n

calendar.leapdays() is a function in Python\u2019s calendar module for creating simple text calendars.<\/p>\n

The leapdays() method returns the number of leap years in a given range of years.
\nThis function works for time spans of a century change.<\/p>\n

Syntax:<\/strong><\/p>\n

leapdays(year1, year2)<\/pre>\n

Parameter Values:\u00a0<\/strong><\/p>\n

year1, year2:<\/strong> These are required. They are numbers. They are the years to get the number of leap years(range).<\/p>\n

Return Value:<\/strong> The number of leap years in a given range is returned.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given lower limit year = 2013\r\nGiven upper limit year = 2025<\/pre>\n

Output:<\/strong><\/p>\n

The number of leap years in a given range{ 2013 , 2025 } = 3<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given lower limit year = 1999\r\nGiven upper limit year = 2002<\/pre>\n

Output:<\/strong><\/p>\n

The number of leap years in a given range{ 1999 , 2002 } = 1<\/pre>\n

Program for calendar leapdays() Method with Examples in Python<\/h2>\n