+ 6

What does '|' imply in python?

8th Apr 2020, 5:09 PM
Ayush Dwivedi
Ayush Dwivedi - avatar
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?
8th Apr 2020, 5:19 PM
Ayush Dwivedi
Ayush Dwivedi - avatar
+ 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.
8th Apr 2020, 5:19 PM
minirkk
minirkk - avatar
+ 2
a = 1 = 01 (Binary) b = 0 = 00 (Binary) a | b = 01 | 00 = 01 = 1 (Decimal) (by ORing)
8th Apr 2020, 5:29 PM
minirkk
minirkk - avatar