Python program to check leap year

leap year:- A leap year is a calendar year which has 366 days. The extra day is a 29 February.

Every four year is a leap year.

How to

  • If a year is not divisible by 4,100 and 400, then it is not a leap year.
  • If a year is divisible by 4 and not 100, then it is not a leap year.
  • If a year is divisible by both 4 and 100 and 400, then it is not a leap year.
  • If a year is divisible by 4, 100 and 400, then it is a leap year.

Program

y=int(input("Please enter the year: "))
 if(y%4)==0:
     if(y%100)==0:
         if(y%400)==0:
             print("{0} is a leap year".format(y))
         else:
             print("{0} is not a leap year".format(y))
     else:
         print("{0} is a leap year".format(y))
 else:
     print("{0} is not a leap year".format(y))

Ourput:-

Please enter the year: 2019
2019 is not a leap year

Leave a Reply