+ 1
Logic operator question
2 Antworten
+ 2
"and" operator expects all expressions to be True. If any expression is False, it will end. In python any number that isn't 0 is True.
Basically, it evaluates 10 (is none-zero) and -2 (none-zero) and as it's the last true expression, it returns the value of the last expression. Which is equivalent to True.
0
c= int( (a==10) and (b==-2)) will output 1.
If you had used "a or b" instead of "a and b" the output would have been 10; the first true expression.