If you aren’t familiar with the idea of a leap year, read “Why Is There a Leap Day?” before continuing with the lab.
Your friend is writing a program that will allow the user to input a year and then print “LEAP!” if that year is a leap year or print “not a leap year” if it is not. However, the program isn’t working properly, and your friend asked you for help in debugging.
Before you take a look at the program, you should know these rules for leap years:
A year is a leap year if it can be divided by 400 without a remainder.
A year is a leap year if it can be divided by 4 without a remainder, unless it can also be divided by 100 without a remainder; if that is the case, it is not a leap year.
All other years are not leap years.
Here is your friend’s code:
year=int(input()
if year%400=0:
print("LEAP!")
else:
print(not a leap year")
elseif year%4==0 and year%100!=0
print(“not a leap year")
Note: You may not have seen the % symbol used this way before. It calculates the remainder of the number to the left of it when it is divided by the number to the right of it. So, 10%3 is 1, because when you divide 10 by 3, the remainder is 1.