Consider this code:
x = 1 # 0001 x << 2 # Shift left 2 bits: 0100 # Result: 4 x | 2 # Bitwise OR: 0011 # Result: 3 x & 1
I hope this clarifies those two:
x | 2 0001 //x 0010 //2 0011 //result = 3
x & 1 0001 //x 0001 //1 0001 //result = 1