Leap Year

#!/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

Comments (0)

  • To add your comment please or

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.

Got It!