Here you will get python program to check leap year.
A normal year contains 365 days while a leap year contains 366 days.
If the year is divisible by 4 then it is leap year except the century years (year that have 00 in end). A century year is leap year only if it is not divisible by 100 but divisible by 400.
For example 2000, 2016 are leap year while 2002, 2017 are not leap year.
Below program ask user to input a year and then check it is leap year or not.
Python Program to Check Leap Year
year = int(input("enter a year: ")) if(year%4==0 and (year%100!=0 or year%400==0)): print("leap year") else: print("not leap year")
Output
enter a year: 2016
leap year
Comment below if you have any queries related to above leap year program in python.
Why do the year%4==0 condition is not enough ?
Correction:
Normal Year = 365 days
Leap Year = 366 days
corrected, thanks for mentioning
#leap year
y=int(input(“Enter the year “))
if(y%4==0) and ((y%100!=0) or( y%400==0))):
print(” Entered year is a leap year “)
else:
print(“Entered year is not leap year”)
what is the meaning of AND and OR in between
here AND means both including this and that.
and OR means either condition 1 or condition 2.