A curated list of good to know Python Snippets. Visit
Advertise with us
program   0   11271
Python program to find whether a given year is leap year or not

We add a Leap Day on February 29, almost every four years. The leap day is an extra, or intercalary day and we add it to the shortest month of the year, February.

In the Gregorian calendar three criteria must be taken into account to identify leap years:

(1) The year can be evenly divided by 4, is a leap year, unless:

        (2) The year can be evenly divided by 100, it is NOT a leap year, unless:
                (3) The year is also evenly divisible by 400, Then it is a leap year.

This means that in the Gregorian calendar, the years 2000 and 2400 are leap years, while 1800, 1900, 2100, 2200, 2300 and 2500 are NOT leap years.

Below is the python code to satisfy above three conditions hence finding whether an inputted year is leap year or not.

# Program to confirm is a given year is leap year or not
# year is provided at runtime.
# Author:

def is_leap(year):
    leap = False
    if year % 4 == 0:
        if year % 100 == 0:
            if year % 400 == 0:
                return True
            return False
        return True
        return False

    return leap

if __name__ == '__main__':

Copy the above code in a file and save it with the name and run using the command python3

program   0   11271

0 thoughts on 'Python Program To Find Whether A Given Year Is Leap Year Or Not'
Leave a comment:

*All Fields are mandatory. **Email Id will not be published publicly.

Please subscribe to get the latest articles in your mailbox.

DigitalOcean Referral Badge

Get a .COM for just $5.98!

© 2021-2022 Python Circle   Contact   Sponsor   Archive   Sitemap   Partner Sites: PythonSnippets.Dev  99Dev.Tools