Look at amplitudes first

Apply a Hadamard gate to |0⟩. The two computational basis outcomes now have equal probability. Applying Z changes the sign of the |1⟩ amplitude while leaving the computational-basis probabilities unchanged. A classical histogram at this step cannot show the sign.

Bring the two paths together

A second Hadamard converts that relative sign into a measurable difference. H followed by H produces |0⟩ from |0⟩. Inserting Z between them instead produces |1⟩. These small circuits show why amplitudes carry more information than their squared magnitudes.

Explore a different phase

Replace Z with S in this example. The phase on |1⟩ becomes a factor of i. Before the final H, the basis probabilities remain the same. After the final H, the outputs are again balanced for a different reason. Inspect the real and imaginary amplitudes alongside the bars.

Further reading

Try a related example