# Leap Year Program in Python – 2023

Hey guys, in this blog we will see a Leap Year Program in Python.

## Code

```# Leap Year Program in Python

year = input('Input the year -> ')

year = int(year)

# divided by 100 means century year (ending with 00)
# century year divided by 400 is leap year
if (year % 400 == 0) and (year % 100 == 0):
print("{0} is a leap year".format(year))

# not divided by 100 means not a century year
# year divided by 4 is a leap year
elif (year % 4 ==0) and (year % 100 != 0):
print("{0} is a leap year".format(year))

# if not divided by both 400 (century year) and 4 (not century year)
# year is not leap year
else:
print("{0} is not a leap year".format(year))```

Output

```Input the year -> 2024
2024 is a leap year```
```Input the year -> 2023
2023 is not a leap year```
```Input the year -> 2021
2021 is not a leap year```

So here we are checking 2 conditions for a year to be a leap year:

1. Either It should be fully divisible by 400 and 100 both to be a Leap Year.
2. Or it should be fully divisible by 4 and not by 100 then also it is a Leap Year.
3. Else it’s not a Leap Year.

So this is how we can check if a year is a Leap Year or not.

Check out our other python programming examples ##### Abhishek Sharma

Started my Data Science journey in my 2nd year of college and since then continuously into it because of the magical powers of ML and continuously doing projects in almost every domain of AI like ML, DL, CV, NLP.

Articles: 521