Advertisement

This space is available for advertisement. Please contact us if interested.

We add a Leap Day on February 29, almost every four years. The leap day is an extra, or intercalary day and we add it to the shortest month of the year, February.

In the Gregorian calendar three criteria must be taken into account to identify leap years:

(1) The year can be evenly divided by 4, is a leap year, unless:

(2) The year can be evenly divided by 100, it is NOT a leap year, unless:

(3) The year is also evenly divisible by 400, Then it is a leap year.

This means that in the Gregorian calendar, the years 2000 and 2400 are leap years, while 1800, 1900, 2100, 2200, 2300 and 2500 are NOT leap years.

Below is the python code to satisfy above three conditions hence finding whether an inputted year is leap year or not.

# # Program to confirm is a given year is leap year or not # year is provided at runtime. # Author: https://www.pythoncircle.com # def is_leap(year): leap = False if year % 4 == 0: if year % 100 == 0: if year % 400 == 0: return True return False return True else: return False return leap if __name__ == '__main__': print(is_leap(int(input())))

Copy the above code in a file and save it with the name `leap_year.py`

and run using the command `python3 leap_year.py`

.

0 thoughts on 'Python Program To Find Whether A Given Year Is Leap Year Or Not'

Leave a comment:

Please subscribe to get the latest articles in your mailbox.

Recent Posts: