Prime #### Prepinsta Prime

Video courses for company/skill based Preparation

(Check all courses)
Get Prime Video
Prime #### Prepinsta Prime

Purchase mock tests for company/skill building

(Check all mocks)
Get Prime mock

# Python Program to Check Leap Year or Not

## Check Given Year is Leap Year or Not​

In this Python Program we have to find the year is a leap year or not.In a year, there are only 365 Days but after every four year there are 366 days in a year. That is nothing but a leap year.The Gregorian calendar provides that a given year that is completely divisible by 100 (for example, 2000) is a leap year only if it is also completely divisible by 400. We can follow these conditions to find whether a given number is leap year or not:
1. If a Year is divisible by 4 and having no remainder. Then we will go to next step.
2. If a year is divisible by 4, but not by 100.
3. If a year is divisible by 100, but not by 400.
These all conditions are true then year is a leap year. ### Working:

Step 1. Enter a value for Year variable.

Step 2. For checking Leap Year, this condition should be satisfied. If a Year is divisible by 4 and having no remainder. Then we will go to next step. If a year is divisible by 4, but not by 100. If a year is divisible by 100, but not by 400.

Step 3. If Condition is true then print, “Yes, {Year} is Leap Year”

Step 4. It is false then print, “No, {year} is not a Leap Year”.

Step 5. Stop.

### Python Program:

```year = int(input("Enter Year:"))
if year % 4 == 0:
if year % 100 == 0:
if year % 400 == 0:
print("Yes, {} is Leap Year".format(year))
else:
print("No, {} is Leap Year".format(year))
else:
print("No, {} is Leap Year".format(year))
else:
print("No, {} is Leap Year".format(year))

# This code is contributed by Shubhanshu Arya (Prepinsta Placement Cell Student)
```

### Output:

```Enter Year:2014
No, 2014 is Leap YearEnter Year:2000Yes, 2000 is Leap Year```

### 3 comments on “Python Program to Check Leap Year or Not”

• Ritwik

More accurate code:
year = int(input(“Enter the year: “))
if ((year%4 == 0 and year%100 != 0) or (year%100 == 0 and year%400 == 0)):
print(year, ” is a leap year”)
else:
print(year, “is not a leap year”) 20
• Bhavantik

Correct one:
year = int(input(“Enter a Year: “))
if year%4 == 0:
if year%100==0 and year%400 !=0:
print(year,” is not a Leap Year”)
else:
print(year,” is Leap Year”)
else:
print(year,” is not a Leap Year”) 16
• HelpPrepInsta

Thanks Bhavantik for contributing the code 4