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)

29th Sep 2022, 7:57 AM
Merie Henry
Merie Henry - avatar
4 Antworten
+ 2
Do you have a question about this?
29th Sep 2022, 8:17 AM
Ausgrindtube
Ausgrindtube - avatar
+ 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.
29th Sep 2022, 11:34 AM
Per Bratthammar
Per Bratthammar - avatar
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
29th Sep 2022, 8:32 AM
ALI Moussa Kadjalla
ALI Moussa Kadjalla - avatar