30th Sep 2022, 6:58 AM
|| H A C K E R Z 2 0 2 1 ||
|| H A C K E R Z 2 0 2 1 || - avatar
2 Respostas
+ 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.
30th Sep 2022, 7:37 AM
Mustafa A
Mustafa A - avatar
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.
30th Sep 2022, 8:42 AM
dan
dan - avatar