0

Why 100!=0? i don't understand

year = int(input()) if year%4!=0: print("Not a leap year") elif year%100!=0: print("Leap year") elif year%400==0: print("Leap year") elif year%400!=0: print("Not a leap year")

23rd Feb 2023, 6:58 AM
AruN
AruN - avatar
5 odpowiedzi
+ 6
The code you provided is related to checking if a given year is a leap year or not. The code is correct and will output "Leap year" if the year is a leap year, and "Not a leap year" if the year is not a leap year. Regarding your question about 100!=0, it's important to note that the != operator in Python means "not equal to". So 100!=0 means "100 is not equal to 0", which is true. However, this expression is not related to the leap year calculation in the code you provided. In the leap year calculation, the logic is as follows: If the year is not divisible by 4, it's not a leap year. If the year is divisible by 4 but not divisible by 100, it's a leap year. If the year is divisible by both 100 and 400, it's a leap year. If the year is divisible by 100 but not divisible by 400, it's not a leap year. This logic is based on the rules for calculating leap years in the Gregorian calendar, which is the calendar used by most of the world today.
23rd Feb 2023, 8:29 AM
Last
Last - avatar
+ 3
Yes but not here. Make your own question.
23rd Feb 2023, 5:15 PM
A͢J
A͢J - avatar
+ 2
How 100 == 0? I don't understand.
23rd Feb 2023, 10:06 AM
A͢J
A͢J - avatar