Question:
Write a python program to find whether a given year is a leap year or not
Program:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# Python program to check if the input year is a leap year or not 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)) |
Explanation:
A leap year is a calendar year containing one additional day added to keep the calendar year synchronized with the astronomical or seasonal year. 2016 is a leap year, which means that it has 366 days instead of the usual 365 days that an ordinary year has. An extra day is added in a leap year—February 29 —which is called an intercalary day or a leap day.
Output:
1.
1 2 |
Enter a year: 2010 2010 is not a leap year |
1 2 |
Enter a year: 2012 2012 is a leap year |
Leave a Reply