In the Gregorian calendar, certain years have 366 days instead of 365. In such years, the month of F…
Click here to read the complete problem statement.
If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.
Please make it clear that this problem uses an incorrect definition of “leap year”.
It says incorrectly “A leap year occurs when the year is a multiple of 4 but not a multiple of 400”.
The correct definition is “Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400. For example, the years 1700, 1800, and 1900 are not leap years, but the year 2000 is”.
Actually, for this problem, you have to check if a year is equally divisible by 4 or not only.
It is not a proper leap year.
Read the problem statement carefully and try again.
I have already answered this uestion couple of times before.
You should check previous posts before posting your problems.
Please check previousw posts before sharing your answer.
year % 4 can return 0, 1, 2 or 3 and the not (!) operator you are using is not logical but bit wise. However this might a bit difficult to explain so, I will ditch the explaination.
To put it simply, Your the int is_leap_year() is will never actually return 1. So, your code should always print No.
Thanks elder your suggestion,I have successfully fix it before .
I use return (year % 400!=0 && year % 4 ==0) ? 1 : 0;
and its works. I have to fix for loop here which was wrong.
n = int(input())
if n % 4 == 0:
print('Yes')
else:
print('No')
This is supposed to be working as @touhidur is saying that you only need to check if the
input is exactly divisible by 4 or not… but it doesn’t work on the 2nd test case.