How to check Leap Year in Python

In this article, we are going to learn How to check Leap Year in Python if a given year is Leap Year or not in Python. We will ask the user to enter the year and then we will check this input year value. If this is a leap year or not we will print a message on the screen.
We will make use of simple if and else condition in Python.

Related Post

Python Program to check Leap year

Program Code Explanation –

  • Take one variable year and store the value entered by the user. Int is used to convert the value entered by the user to integer or for integer type value and the input() function is used for taking the value from the user.
  • If a year is divided by 400 or 4 and the remainder is equal to 0 and divided by 100 reminders is not equal to 0 then print the year as a leap year.
  • Else the year is not a leap year.
year = int(input("Enter Year:"))
if(year % 400 == 0) or (year % 100! == 0) and (year % 4 == 0):
   print(year," is Leap Year")
    print(year," is not a Leap Year")


Enter Year:2000
2000 is Leap Year

Enter Year:2001
2001 is not a Leap Year