Python Program to Check Leap Year

A year, occurring once every four years, which has 366 days including 29 February as an intercalary day.

Python Program to Check Leap Year

A leap year is exactly divisible by 4 except for century years (years ending with 00). The century year is a leap year only if it is perfectly divisible by 400. For example,

2020 is Leap Year
2000 is Century Leap Year

To understand this example, you should have knowledge of following Python programming topics:

Source Code: Python Program for Checking Leap Year and Century Leap Year

yr = int(input("Enter a year:"))
if yr % 4 == 0:
    if yr % 100 == 0:
        if yr % 400 == 0:
            print("{} is a century leap year" . format(yr))
        else:
            print("{} is not a leap year" . format(yr))
    else:
        print("{} is a simple leap year". format(yr))
else:
    print("{} is not a leap year" . format(yr))

It’ also available on GitHub – https://github.com/studygyaan/python-tutorial/blob/master/Python-Leap-Year.py

Share