+ 2
What does the vertical line( | ) mean in PYTHON?
for example: why 10|20 =30, and 10|10 =10?
5 Answers
+ 23
(|) is a Bitwise OR operator
if any one or both of the bits is 1,
it results 1
if both the bits are zero 0, it results in 0
10|20 = 30
Binary Decimal
0000 1010 10 |
0001 0100 20
--------------------------------------
0001 1110 30
1|0 = 1 1&0 = 0
1|1 = 1 1&1 = 1
0|0 = 0 0&0 = 0
Check out the lesson 👇
https://www.sololearn.com/learn/4073/?ref=app
+ 28
Markus Kaleton Yes xor (^)
1^1 = 0 0^0 = 0
1^0 = 1 0^1 = 1
when the bits of operands on both side of ^ operators are same then the result is 0
if different result is 1...
here's the lesson 👇
https://www.sololearn.com/learn/4074/?ref=app
+ 1
bitwise or
0
🌛DT🌜 followup question. does the bitwise operation do xor? 0+0=0, 1+0=1, 0+1=1, 1+1=0?
0
cheers