Python Armstrong NumberPython Average of N NumbersPython Biggest of Three NumbersPython Common DivisorsPython Composite NumberPython Condense a NumberPython Even NumberPython Factorial of a NumberPython Fibonacci SeriesPython GCDPython LCMPython Leap YearPython Multiplication TablePython Number CombinationPython Odd NumberPython Palindrome NumberPython Perfect NumberPython Prime FactorPython Prime NumberPython Sum of DigitsPython Swapping Two Numbers

Python Array ProgramsPython Converter ProgramsPython Star Patterns ProgramPython Number Patterns ProgramPython Alphabet Patterns ProgramLast Updated:

A leap year is a calendar year containing one additional day added to keep the calendar year synchronized with the astronomical or seasonal year. For example, 2024 is a leap year.

**Tips**: It is recommended to use our online Leap Year calculator for better understanding.

To check whether a year is a leap year or not, the year should satisfy at least one of the following two conditions

- A year should be exactly divisible by 4, but, not by 100.
- A year should be exactly divisible by 4, 100 and 400 at the same time.

In the following example, we will check whether the given year (2012) is leap year or not.

Python Compiler

year = 2012
if(year % 4 == 0):
if((year % 100 == 0) and (year % 400 != 0)):
print("%d is not a leap year" % year)
else:
print("%d is a leap year" % year)
else:
print("%d is not a leap year" % year)

In the following example, we will find all the Leap Years between 2000 and 2030.

Python Compiler

start = 2000
end = 2030
print("Leap years between %d and %d: " %(start, end))
for start in range(start, end):
if(start % 4 == 0):
if((start % 100 == 0) and (start % 400 != 0)):
pass
else:
print(start, end=" ")

In the following example, we will check whether the given year is a leap year or not.

Python Compiler

year = int(input("Enter a year: "))
if(year % 4 == 0):
if((year % 100 == 0) and (year % 400 != 0)):
print("%d is not a leap year" % year)
else:
print("%d is a leap year" % year)
else:
print("%d is not a leap year" % year)