+ 6
What does '|' imply in python?
5 Answers
+ 2
Hi RRK
Suppose if I were to type in
Print (1|0)
Its output is 1
So can you explain the result?
+ 2
Muntasir R Tamim your are wrong!
it's union of sets
for example,
A = {1,2,3}
B = {2,3,4}
print(A|B)
output : {1,2, 3,4}
& means intersection of sets.
for example,
A = {1,2,3}
B = {2,3,4}
print(A&B)
output : {3,4}
here A and B are sets.
+ 2
a = 1 = 01 (Binary)
b = 0 = 00 (Binary)
a | b = 01 | 00 = 01 = 1 (Decimal) (by ORing)



