Leap Year

Python Programming

Python Programming Examples

 #!/usr/bin/evn python
 
 # Take year as input from the user
year = int(input("Enter a year: "))

# Compare mod value of the year with zero
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: 2016
2016 is a leap year

#or

Enter a year: 2017
2017 is a leap year

Learn more about If statement