leapdays() function in python by R4R Team

- leapdays() is a python function which count the number of leap years between the two years.

Syntax-

calendar.leapdays(year1,year2)

Example-

calendar.leapdays(2015,2021) will return 2
because [2016,2020] are two leap years between 2015,2021


program-

#import calendar module
import calendar

print("Enter starting year")
y1=int(input())
print("Enter final year")
y2=int(input())

print("Number of Leap years in between given year is")
print(calendar.leapdays(y1,y2))


output-

Enter starting year
1089
Enter final year
2020
Number of Leap years in between given year is
225

Enter starting year
2011
Enter final year
2021
Number of Leap years in between given year is
3


-In this program, we take an input of two years and then using leapdays() function we count the number the of leap years between given years.




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!