Considering the following
>>> a = 10
>>> b = 5
What is the difference between adding the values to c
using +
or |
?
>>> c = a + b
>>> c
15
>>> c = a | b
>>> c
15
I ask this question based on this answer where binary and bitwise operations are used, if that makes any difference.
From the answer linked above:
>>> mon, tue, wed, thu, fri, sat, sun = (pow(2, i) for i in range(7)) >>> bin(mon) '0b1' >>> bin(sun) '0b1000000' # create range: >>> x = mon | wed | fri >>> bin(x) '0b10101' # check if day is in range: >>> x & mon 1 >>> x & tue 0