A growing list of bit twiddles as I come across them.

If we XOR with 1 we flip a bit. Therefore to flip all the bits in a 32-bit integer:

1

def flippingBits(n): return n ^ int('11111111111111111111111111111111', 2)

where the number of 1s in the string is 32.

32