How to check if a year is a leap year using Python?

PythonServer Side ProgrammingProgramming

not a leapyear using Python. The calender module has a special function, isleap(year), that returns True if year is a leap year, otherwise it returns False.

Example

import calendar
print(calendar.isleap(1995))
print(calendar.isleap(2008))
print(calendar.isleap(2004))

Output

This will give the output −

False
True
True
raja
Published on 08-Jan-2018 12:40:25
Advertisements