# Python Program to Check Leap Year

A**leap year**is a year that is divisible by 4, except for end-of-century years which must be divisible by 400. Here is a

**Python program**that checks if a given year is a leap year or not:

year = 2005
if year % 4 == 0 and (year % 100 != 0 or year % 400 == 0):
print(year, "is a leap year.")
else:
print(year, "is not a leap year.")

//Output:2005 is not a leap year.

Here, the program checks if the year is **divisible by 4**and either not

**divisible by 100**or

**divisible by 400.**If the year satisfies this condition it is considered as leap year otherwise not. You can also use a function to check for

**leap year**like this:

year = 2010
if is_leap_year(year):
print(year, "is a leap year.")
else:
print(year, "is not a leap year.")
def is_leap_year(year):
return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)

//Output:2010 is not a leap year.

In this example, the input year is passed as an argument to the function **is_leap_year(),**which returns True if the year is a leap year and False otherwise. The result is then used to print the appropriate message.

## Leap Year

A leap year is a year that is

**divisible by 4,**except for end-of-century years which must be

**divisible by 400.**For example, the year 2000 was a leap year because it is divisible by 4 and

**divisible by 400.**The year 1900 was not a leap year because it is divisible by 4, but not divisible by 400. The year 2021 is not a leap year because it is not

**divisible by 4.**Leap years are added to the calendar to keep it in sync with the

**solar year,**which is about 365.25 days long. Without leap years, the

**calendar**would gradually drift out of sync with the seasons. In the

**Gregorian calendar,**which is the calendar system used in most of the world today, leap years have

**366 days**instead of the usual 365 days.

**February 29th**is added as an extra day to the calendar in leap years. It is important to note that

**leap years**are not only used in Gregorian calendar, but also in other calendar systems like

**Julian calendar.**

**Related Topics**

- Print the following pattern using python
- Remove first n characters from a string | Python
- Check if the first and last number of a list is the same | Python
- Number of occurrences of a substring in a string in Python
- Remove last element from list in Python
- How to Use Modulo Operator in Python
- Enumerate() in Python
- Writing to a File using Python's print() Function
- How to read csv file in Python
- Dictionary Comprehension in Python
- How to Convert List to String in Python
- How to convert int to string in Python
- Random Float numbers in Python