isleap() function in python by R4R Team

- isleap() is a python function which is predefined in the calendar module.
-Work of isleap() function is to check the year is leap year or not.

Syntax-

calendar.isleap(year)

-It return True if year is leap year otherwise return False

Example-

calendar.isleap(2016) will return True
calendar.isleap(2018) will return False


program-

import calendar

print("Enter year to check it is leap year or not")
y=int(input())
c=calendar.isleap(y)
print(c)

if c==True:
print(y,'is leap year')
else:
print(y,'is not leap year')


output-

Enter year to check it is leap year or not
2016
True
2016 is leap year

Enter year to check it is leap year or not
2003
False
2003 is not leap year


-In this program, we take an input of the year and check it is leap year or not by the isleap() function.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!