A Program to Check Leap Year

In this example, we are giving a program to check a given year by user is leap year or not.


Program to swap to check leap year:

  1. # Check a given year by user is leap year or not
  2. year = float(input('Enter a year: '))
  3. if(year % 4 ) == 0:
  4. if(year % 100 ) == 0:
  5. if(year % 400 ) == 0:
  6. print("{0} is a leap year".format(year))
  7. else:
  8. print("{0} is not a leap year".format(year))
  9. else:
  10. print("{0} is a leap year".format(year))
  11. else:
  12. print("{0} is not a leap year".format(year))

Output:

Enter a year: 2000
2000.0 is a leap year