Python Program to Check if the Year is a Leap Year or Not

Check if a Year is a Leap Year or Not in Python

Given an integer input for a year, the objective is to check whether the given integer input represents a Leap year or not. In order to do so, we’ll check for two conditions, any year to be a leap year must satisfy either of them.

Example

Input: 2020

Output: It's a Leap Year

Flow Diagram:-

Leap year or not.png

Code:-

  • step 1: Start

  • step 2: Read year

  • step 3: if year%4=0 and year%100!=0 or if year%4=0 and year%400=0 then go to step 4
    else go to step5

  • step 4: print a leap year

  • step 5: print not a leap year

  • step 6: Stop

Algorithm:-

Code:-

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

Output:-

2100

2100 is not a Leap Year