Skip to content
Home » Leap Year Program in Python

Leap Year Program in Python

Learn about Leap Year Program in Python in the below code example. Also, refer to the comments in the code snippet to get a detailed view about what’s actually happening.

Leap Year Program in Python

Except for century years, a leap year is exactly divisible by four (years ending with 00). Only if the century year is perfectly divisible by 400 is it a leap year. The below program checks whether the given year is a leap year or not.

Program:

# Python program to check year is a leap year or not

# input year
year = int(input('Enter a year: '))

# check leap year or not
if (year % 400) == 0:
    print('{0} is a leap year'.format(year))
elif (year % 100) == 0:
    print('{0} is not a leap year'.format(year))
elif (year % 4) == 0:
    print('{0} is a leap year'.format(year))
else:
    print('{0} is not a leap year'.format(year))

Output:

Enter a year: 2004
2004 is a leap year

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Code : Print Multiplication Table in given Range Python