9%3==0 & 9%5==0
Expected result value: False, Actual result value: True
I know that this result comes out because of the difference in the order of calculation I wonder how the expression that comes out after calculating & comes out true.
9%3==(0 & 9%5)==0 Even if I tie it like this, it doesn't come out true...
python3.7
I just looked it up and found that &
and and
are different in Python.
and
is an operator that determines whether both sides are logically True
and is an operator that determines whether both sides are
True
and (when used with the True
value). Source
Therefore:
print(9 % 3 == 0 & 9 % 5 == 0) # True
print(9 % 3 == 0 and 9 % 5 == 0) # False
Python... You can't let your guard down...
© 2024 OneMinuteCode. All rights reserved.