Skip to content
Home » Python Programs » Python Program to Check Leap Year Using Function

Python Program to Check Leap Year Using Function

Simple python program to check leap year using function. In this program we can execute the leap year program using function in python programming language for beginners.

Leap Year Definition

A leap year is a calendar year in which an extra day is added to keep the calendar year in sync with the astronomical or seasonal year. a year in the Gregorian calendar with 366 days and an extra day on February 29. 

The year number must be divisible by four to be a leap year, with the exception of end-of-century years, which must be divisible by 400. This means that, unlike 1900, the year 2000 was a leap year. All of the years 2020, 2024, and 2028 are leap years.

Function Definition in Python

A function is a piece of code that only executes when called. If a return statement is specified, Python functions return a value. After a function has been declared, it can be called from anywhere. 

A function is a named section of code in computer programming that performs a specific task. This usually entails taking some data, manipulating it, and then returning a result. Here we have executed the python program to check leap year using function 

Python Program to Check Leap Year Using Function

def leap(year):
    if (year % 4) == 0:
        if (year % 100) == 0:
            if (year % 400) == 0:
                return True
            else:
                return False
        else:
             return True
    else:
        return False
year = 3200
if(leap(year)):
    print("Leap Year")
else:
    print("It is Not a Leap Year")

Output:

It is Leap Year