O'Reilly logo
  • Nedda Kaltcheva thinks this is interesting:

In the first expression, a binary 1 (in base 2, 0001) is shifted left two slots to create a binary 4 (0100). The last two operations perform a binary OR to combine bits (0001|0010 = 0011) and a binary AND to select common bits (0001&0001 = 0001)

From

Cover of Learning Python, 5th Edition

Note

0001 -- 1x2exp0 = 1 0100 -- 1x2exp2 = 4