In this Python tutorial, you will learn about **Python Program to Check Leap Year **and, also we will check**:**

- Python Program to check leap year
- Python program to check leap year by getting input from a user
- Python program to check leap year using function
- Python program to find the input year is leap or not in python
- Python program to check leap year using if statement

Contents

## Python program to check leap year

Let see** python program to check leap year**

- In this example, we will first take a variable as
**Year = 2024**. - If a year is evenly divisible by 4 and having no remainder then go to the next step. If it is not divisible by 4. It is not a leap year.
- If a year is divisible by 4, but not by 100, it is a leap year. If a year is divisible by both 4 and 100, go to the next step.
- If a year is divisible by 100, but not by 400 then it is not a leap year. If a year is divisible by both then it is a leap year.
- At last, it
**prints**whether the year is a leap year or not.

**Example:**

```
Year = 2024
if (Year % 4) == 0:
if (Year % 100) == 0:
if (Year % 400) == 0:
print("{0} is a leap year".format(Year))
else:
print("{0} is not a leap year".format(Year))
else:
print("{0} is a leap year".format(Year))
else:
print("{0} is not a leap year".format(Year))
```

You can refer to the below screenshot to see the output for the python program to check leap year.

The above code we can use to **check leap year in Python**.

Check out, How to find area of a triangle in Python.

## Python program to check leap year by getting input from a user

Here, we will see **python program to check leap year by getting input from a user**

- Firstly, we will allow the
**user**to enter any year. - If a year is evenly divisible by 4 and having no remainder then go to the next step. If it is not divisible by 4. It is not a leap year.
- If a year is divisible by 4, but not by 100, it is a leap year. If a year is divisible by both 4 and 100, go to the next step.
- If a year is divisible by 100, but not by 400 then it is not a leap year. If a year is divisible by both then it is a leap year.
- At last, it
**prints**whether the year is a leap year or not.

**Example:**

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

You can refer to the below screenshot to see the output for the python program to check leap year by getting input from a user.

The code we can use to **check leap year by getting input from a user in Python**.

Also, read, Python program to find the area of square.

## Python program to check leap year using function

Now, we will see **python program to check leap year using function**

- Firstly, we will
**define a function**with arguments using**def**keywords. - return true if the year is multiple of 4 and not a multiple of 100 or year is multiple of 400.
- The variable is defined as
**year = 3200**and the value is passed to the function argument. - At last,
**print**year is leap or not.

**Example:**

```
def CheckYear(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(CheckYear(year)):
print("Leap Year")
else:
print("It is not a Leap Year")
```

You can refer to the below screenshot to see the output for the python program to check leap year using function.

The above code, we can use to **check leap year using function in Python**.

Also read, Python program to find an area of a rectangle.

## Python program to find the input year is leap or not

Here, we will see **python program to find the input year is leap or not in python**

- Firstly, we will allow
**users**to enter the year. - Then we will use the if condition to check whether the entered year is a leap year or not.
- At last, it will
**print**the entered year is leap or not.

**Example:**

```
Year = int(input("Enter a Year: "))
if Year % 4 == 0 and Year % 100 != 0:
print(Year, "is a Leap Year")
elif Year % 100 == 0:
print(Year, "is not a Leap Year")
elif Year % 400 ==0:
print(Year, "is a Leap Year")
else:
print(Year, "is not a Leap Year")
```

You can refer to the below screenshot to see the output for the python program to find the input year is leap or not.

This is the Python program to find the input year is leap or not.

Also, check out, How to calculate area of a circle in Python.

## Python program to check leap year using if statement

Let’s see** python program to check leap year using if statement**

- In this example, we will allow the
**user**to enter any year. - Now, we will use the if-else condition to check whether the year is a leap or not.
- Here, we will check multiple conditions within one if statement, and we have used Logical AND and Logical OR operators.
- The first condition
**(Year%400 == 0)**will check whether the year remainder is exactly equal to 0 or not. So if any number is divisible by 400 is a leap year. - And the second statement holds 2 statements with
**Logical AND**operator, so they both have to be true. - The
**( Year%4 == 0 )**will check whether the remainder of the year is exactly equal to 0 or not. If the condition is false then it will exit from the condition because it is definitely not a leap year. - At last, it
**prints**whether the year is a leap or not.

**Example:**

```
Year = int(input("Enter the Year: "))
if (( Year%400 == 0) or (( Year%4 == 0 ) and ( Year%100 != 0))):
print("%d is a Leap Year" %Year)
else:
print("%d is Not the Leap Year" %Year)
```

You can refer to the below screenshot to see the output for the python program to check leap year using the if statement.

This code, we can use to **check leap year using if statement in Python**.

Also, check out:

- How to calculate simple interest in Python
- Python program to print pattern
- How to print factorial of a number in Python

In this Python tutorial, we have learned about the **Python Program to Check Leap Year**. Also, we covered these below topics:

- Python Program to check leap year
- Python program to check leap year by getting input from a user
- Python program to check leap year using function
- Python program to find the input year is leap or not in python
- Python program to check leap year using if statement

Entrepreneur, Founder, Author, Blogger, Trainer, and more. Check out my profile.