Python Program to check whether the Year is Leap Year
#python #program #question #leap #year
Logic of Leap year program:
if the year is divisible by 400 then the year is a leap year
Example: 1600, 2000, 2400, and so on
if the year is divisible by 4 but not by 100 is a leap year
Source code of Python Program to check whether the Year is Leap Year or Not
def is_leap_year(year):
if ((year % 4 == 0 and year % 100 != 0) or year % 400 ==0):
print (year, "is a leap year")
else:
print (year, "is not a leap year")
year = int (input("Enter the year: "))
is_leap_year(year)
Case 1:
Enter the year: 2000
2000 is a leap year
Case 2:
Enter the year: 1600
1600 is not a leap year
Case 3:
Enter the year: 2020
2020 is a leap year