Quantum Computing & Cryptography  
010000101110011010100111101101101110100110111111000010101000100110101001101110101101100010100111100000111111010010100001101000101011111111100010101100111111100000101011011110011010101101111111

CNOT:   creating entangled states

    initially a = |0>+|1>, b = |0>

    q   a b   p -> a b⊕a              class TwoQubit:
    0   0 0  0.5   0 0  0.5             def cnot(self):
    1   0 1        0 1                      '''Controlled NOT operation'''
    2   1 0  0.5   1 0                      self.onezero, self.oneone = self.oneone, self.onezero
    3   1 1        1 1  0.5                 return self

    Using an array:                     Using names for the complex amplitudes:

    q[0], q[1], q[2], q[3]              zerozero, zeroone, onezero, oneone

    swap q[2] and q[3]                  Python Quantum Computing simulator, Juliana Peña, 2011.