Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

We add a Leap Day on February 29, almost every four years. The leap day is an ex

ID: 3745059 • Letter: W

Question

We add a Leap Day on February 29, almost every four years. The leap day is an extra day and we add it to the shortest month of the year, February. There are three criteria to identify leap years: The year can be evenly divided by 4, is a leap year, unless: The year can be evenly divided by 100, it is NOT a leap year, unless: 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. Your task is to write a program to input an integer variable. Write a function to verify whether the integer is a leap year or not. The function should return True/False.

Explanation / Answer

year = int(input("Input:")) # taking user input

leap = False # By default, making it zero

if year % 400 == 0: # if it is a multiple of 400, it is leap

leap = True

elif year % 100 != 0 and year % 4 == 0: # if it is not a multiple of 100 but of 4, it is leap

leap = True

print("Output:", leap)

''' SAMPLE OUTPUT

Input: 1900

Output: False

Input: 1992

Output: True

'''

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote