The X gate, also called the NOT gate, swaps the amplitudes associated with the two computational-basis outcomes of a single-qubit state. section 3.2.2
Simulating an X gate
Represent the state as a two-item list and exchange its entries: state = [state[1], state[0]]. This directly models the amplitude swap. section 3.2.2
Applying the gate twice
Starting with the default state [0, 1], one X transformation produces the swapped state, and applying the same transformation again returns [1, 0]. section 3.2.5

