0
Replacement of True or False with Numericals
>>> False == False or True True >>> False == (False or True) False >>> (False == False) or True True can anyone please help? if i replace the statement with numbers: print(1==1.0 or 2) print(2==(2 or 1)) print((2==2)or 1) the solution is true in all the cases but false in the 2nd case for the given example. why?
3 ответов
+ 1
often in dev, False like 0 and all other value is True
then 0 or 1 = 1
see wiki truth table - Logical disjunction (OR)
with numbers, replace 1 by 0 and the result are similary than False and True
+ 1
Hi,
1/
False == False or True like (False == False) or True
so False == False result True
then True or True => True
2/
False == (False or True)
so (False or True) => True
then False == True => False
3/
(False == False) or True
so (False == False) => True
then True or True => True
0
Thanks a lot for the answer, now I got the concept and it's clear to me. Just two more questions if you don't mind.. why(False or True)=> True, does true has a precedence over false? Secondly, what about the numbers, why do they all show as true?