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:
# Check a given year by user is leap year or not
year = float(input('Enter a year: '))
if(year % 4 ) == 0:
if(year % 100 ) == 0:
if(year % 400 ) == 0:
print("{0} is a leap year".format(year))
else:
print("{0} is not a leap year".format(year))
else:
print("{0} is a leap year".format(year))
else:
print("{0} is not a leap year".format(year))
Output:
Enter a year: 2000 2000.0 is a leap year