Check Leap Year Program in Python
Here you will get the source code of leap year program in python programming. In this program, we will use if-else(conditional statement ).
What is a leap year?
Leap year occur every four years, with the exception of century years (years ending in 00). A year that is divisible by 4 with the exception of years that are divisible by 100 but not by 400.
Example code of Leap Year Program in Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #Python Program to Check Leap Year year = int(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 1
Enter a year: 2001
2001 is not a leap year
Output 2
Enter a year: 2020
2020 is a leap year
Check out our other Python Programming Examples