A year, occurring once every four years, which has 366 days including 29 February as an intercalary day. We Talk About How to Check leap Year In Python Program.

What Is Leap Years.

Earth goes around the Sun every year for about 365 days. To make up for the missing days, we often add a day to our calendar every four years And Show How to Check leap Year In Python Program.

How to determine if a year is a leap year?

If you want to determine whether a year is a leap year or not, follow these steps.

  1. In the case of a year being evenly divisible by 4 meaning that there is no remainder, then proceed to step two. If the year is not divisible by 4, it is not a leap year. For instance, 1997 is not a leap year.

2. When a year is divisible by four, but not by 100. For example, 2012, it is a leap year. If a year is divisible by both four and 100, proceed to the next step.

3. If a year is divisible by 100, but not by 400. For example, 1900, then it is not a leap year. If a year is divisible by both, then it is a leap year. Therefore, 2000 is a leap year.

4. A leap year is a year that has an additional day that makes the number of days in the year 366. The extra day is added in February, which makes it 29 days long.

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

Python Program to Check Leap Year
Python Program to Check Leap Year