0
Confused. Why is it printing just one value???
# Created by Python Learner print(0 and 1) print(1 and 1) print() print(2 and 3) print(3 and 2)
4 Answers
+ 2
Do you have a question about this?
+ 2
Hi, ALI Moussa Kadjalla !
In Python, when using āandā and āorā in an expression, Python will deliver the value that first decides the expressions outcome.
In Python every object is either truthly or falsy. For integers 0 is the only falsy value. Every other value is truthly.
For exampel: to decide A and B
To know if the expression is true, Python have to examine both A and B. It start from left with A, and if it isnāt a 0, it examine B. So the result become B. If A is 0, itās enough to decide the expression is falsy, so it deliver A as a result.
0
Hi, Merie Henry !
You can read more here:
https://www.freecodecamp.org/news/truthy-and-falsy-values-in-JUMP_LINK__&&__python__&&__JUMP_LINK/amp/
0
and (Sets each bit to 1 if both bits are 1)
Example
Bits of 0 is 0 and of 1 is 1 now mutliple each bit
0
*
1
--
0 (bit of 0)
So the output is 0
By example
print(1 and 1)
Bit of 1 is 1 and of 1 is 1
1
*
1
--
1
The output is 1
Also
print(3 and 2)
Bit of 3 is 11 and of 2 is 10
11
*
10
--
10 (bit of 2)
The output is 2
Keept well and good luck the do the reset example