In this post, we will make a python program to check whether the given year is a leap year.

Leap Year: One year in every four has 366 days [February has 29 days instead of 28]. The reason why we have leap years is really fascinating, this video does more justice: Video Link

## Algorithm:

If one of the following conditions is satisfied then the given year is a leap year.- Every year that is divisible by 4 and not divisible by 100.
- A year that is divisible by 4 and also divisible by 400.

## Leap Year Program in Python using if-else

In this program, we will check for leap year using simple if-else conditions. We will take input from the user and typecast it to int and then check whether the given year is a leap year or not using the above algorithm.

year = int(input("Which year do you want to check? ")) if (year%4==0 and year%100!=0) or (year%4==0 and year%400==0): print("Leap year.") else: print("Not leap year.")

Output:

`
Which year do you want to check? 2022
Not leap year.
`

**Related Posts :**

## leap year program in python hackerrank solution

In this program, we will code answers for the leap year question at hackerrank. We completed the is_leap function and it will return true when the given year is a leap year and false otherwise.

def is_leap(year): leap = False # Write your logic here if (year%4==0 and year%100!=0) or (year%4==0 and year%400==0): leap=True return leap year = int(input()) print(is_leap(year))

I hope you like this post, if you like this post please comment and if you are new to our blog please subscribe to our newsletter. Thank you so much for reading.

If you are looking for jobs/internships, you may join our telegram for the latest jobs and internships updates.

If you are looking for jobs/internships, you may join our telegram for the latest jobs and internships updates.