Python Program to Check Leap Year

In this post, we will see how to check if given year is leap year or not.


Problem

Leap year is the year which has 366 days including 29 feb in a year.
Here is formula for calculating leap year.
If Year is divisible by 4 and (not divisible by 100 or divisble by 400) then it is a leap year.


Program to check leap year

year=2012 #uncomment below line if you want to take input from user #year = int(input("enter a year: ")) if(year%4==0 and (year%100!=0 or year%400==0)): print(year,"is leap year") else: print(year,"is not leap year")

Output:

2012 is leap year

That’s all about checking leap year in python.

Leave a Reply

Your email address will not be published. Required fields are marked *