Quantum Gates Cheat Sheet: X, Y, Z, H, S, T, CNOT, and SWAP in Plain English
Quantum GatesCheat SheetReferenceBasics

Quantum Gates Cheat Sheet: X, Y, Z, H, S, T, CNOT, and SWAP in Plain English

SSharp Qbit Editorial
2026-06-10
10 min read

A practical quantum gates cheat sheet covering X, Y, Z, H, S, T, CNOT, and SWAP with plain-English explanations and code examples.

If you write or read quantum circuits often, you do not need a long theory lecture every time you see X, H, or CNOT. You need a reliable reference that tells you what each gate does, when to use it, what changes after measurement, and how to express it in common Python quantum computing libraries. This plain-English quantum gates cheat sheet is built for that purpose. It covers the core single-qubit and two-qubit gates developers meet first—X, Y, Z, H, S, T, CNOT, and SWAP—with intuitive explanations, simple state transformations, and quick examples in Qiskit, Cirq, and PennyLane. Keep it nearby as a practical quantum gate reference while learning, debugging circuits, or comparing framework syntax.

Overview

This article gives you a reusable quantum gates cheat sheet for day-to-day development. Instead of treating gates as abstract symbols, it explains them as concrete operations on qubits and links each one to common programming tasks.

A useful mental model is this: a gate is an instruction that changes a qubit's state before measurement. Some gates flip values, some change phase, some create superposition, and some entangle multiple qubits. If you are doing quantum programming for beginners or reviewing a circuit written by someone else, those four ideas carry most of the practical load.

Before the gate-by-gate reference, it helps to remember three rules:

  • Measurement is not the same as state. Two states can measure the same in the computational basis and still behave differently later because of phase.
  • Order matters. Applying H then Z is not generally the same as applying Z then H.
  • Controlled gates add correlation. Once you move from one qubit to two, gates like CNOT often create entanglement rather than just independent flips.

Throughout this cheat sheet, we refer to the basis states |0⟩ and |1⟩, and to the common superposition states:

  • |+⟩ = (|0⟩ + |1⟩)/√2
  • |-⟩ = (|0⟩ - |1⟩)/√2

If that notation still feels new, do not worry. The plain-English interpretation matters more than the algebra at this stage. For a broader foundation in Python quantum computing libraries, see Quantum Computing with Python: Best Libraries and When to Use Each.

Template structure

Use this section as the actual quick-reference layer. Each gate includes what it does, what it is good for, what to watch for, and basic code snippets across major frameworks.

X gate

Plain English: The X gate is the quantum version of a NOT gate. It flips |0⟩ to |1⟩ and |1⟩ to |0⟩.

State action:

  • X|0⟩ = |1⟩
  • X|1⟩ = |0⟩

Why it matters: This is often the first gate used to prepare a qubit in |1⟩. It is also useful inside controlled operations and test circuits.

Common misunderstanding: Developers sometimes assume all useful gates must create superposition. Not true. A simple flip gate is often exactly what a circuit needs.

# Qiskit
qc.x(0)

# Cirq
circuit.append(cirq.X(qubits[0]))

# PennyLane
qml.X(wires=0)

Y gate

Plain English: The Y gate flips the qubit like X, but also adds a phase factor. In practice, it is a bit-and-phase flip.

State action:

  • Y|0⟩ = i|1⟩
  • Y|1⟩ = -i|0⟩

Why it matters: You will see Y less often in basic introductions, but it appears in Hamiltonians, rotations, and many variational quantum circuit examples.

Common misunderstanding: Since measurement probabilities in the computational basis may look similar to X in some simple cases, beginners sometimes think Y is redundant. It is not. The phase change affects later gates and interference.

# Qiskit
qc.y(0)

# Cirq
circuit.append(cirq.Y(qubits[0]))

# PennyLane
qml.Y(wires=0)

Z gate

Plain English: The Z gate does not flip |0⟩ and |1⟩ the way X does. Instead, it leaves |0⟩ alone and changes the phase of |1⟩.

State action:

  • Z|0⟩ = |0⟩
  • Z|1⟩ = -|1⟩

Why it matters: This is one of the most important “invisible until later” gates. On a basis state measured immediately, the effect may seem unimportant. But when superposition is involved, Z changes interference patterns in a meaningful way.

Developer shortcut: If X is a bit flip, Z is a phase flip.

# Qiskit
qc.z(0)

# Cirq
circuit.append(cirq.Z(qubits[0]))

# PennyLane
qml.Z(wires=0)

H gate

Plain English: The Hadamard gate, written H, creates and removes equal superposition. It is one of the most recognizable gates in quantum circuits.

State action:

  • H|0⟩ = |+⟩
  • H|1⟩ = |-⟩

Why it matters: If you want a qubit to have a 50/50 chance of measuring as 0 or 1, H is often the first step. It is also central to algorithms that rely on interference.

Common misunderstanding: H does not mean “randomize.” It creates a specific, coherent superposition, which is very different from classical randomness.

# Qiskit
qc.h(0)

# Cirq
circuit.append(cirq.H(qubits[0]))

# PennyLane
qml.Hadamard(wires=0)

S gate

Plain English: The S gate is a phase gate. It leaves |0⟩ unchanged and rotates the phase of |1⟩ by a quarter turn.

State action:

  • S|0⟩ = |0⟩
  • S|1⟩ = i|1⟩

Why it matters: It appears in phase-sensitive circuits, basis changes, and gate decompositions. It is also useful as a stepping stone toward understanding the T gate.

Shortcut relationship: Applying S twice gives Z.

# Qiskit
qc.s(0)

# Cirq
circuit.append(cirq.S(qubits[0]))

# PennyLane
qml.S(wires=0)

T gate

Plain English: The T gate is another phase gate, smaller than S. It applies an eighth-turn phase shift to |1⟩.

State action:

  • T|0⟩ = |0⟩
  • T|1⟩ = e^(iπ/4)|1⟩

Why it matters: In many discussions of fault-tolerant quantum computing, the T gate shows up because it is powerful but often expensive in error-corrected settings. Even if you are working only with simulators, it is useful to know why this gate gets special attention.

Shortcut relationship: Applying T twice gives S.

# Qiskit
qc.t(0)

# Cirq
circuit.append(cirq.T(qubits[0]))

# PennyLane
qml.T(wires=0)

CNOT gate

Plain English: The controlled-NOT gate, usually written CNOT or CX, flips a target qubit only if the control qubit is |1⟩.

Basis action:

  • |00⟩ → |00⟩
  • |01⟩ → |01⟩
  • |10⟩ → |11⟩
  • |11⟩ → |10⟩

Why it matters: This is one of the core entangling gates. A common pattern is H on the first qubit, then CNOT. That combination can create a Bell state.

Common misunderstanding: CNOT is not just “if statement logic.” In superposition, the result can be entangled, not merely conditionally updated.

# Qiskit
qc.cx(0, 1)

# Cirq
circuit.append(cirq.CNOT(qubits[0], qubits[1]))

# PennyLane
qml.CNOT(wires=[0, 1])

If you want to understand why entangling gates become costly on real devices, read Quantum Circuit Depth Explained: Why It Limits Real Hardware Performance.

SWAP gate

Plain English: The SWAP gate exchanges the states of two qubits.

Basis action:

  • |00⟩ → |00⟩
  • |01⟩ → |10⟩
  • |10⟩ → |01⟩
  • |11⟩ → |11⟩

Why it matters: On paper, SWAP looks simple. On hardware, it is often important because some devices only allow certain qubits to interact directly. A SWAP can move quantum information across the chip so the needed two-qubit gate becomes possible.

Practical note: In many systems, a SWAP is decomposed into multiple native gates, so it may add nontrivial cost.

# Qiskit
qc.swap(0, 1)

# Cirq
circuit.append(cirq.SWAP(qubits[0], qubits[1]))

# PennyLane
qml.SWAP(wires=[0, 1])

How to customize

This section helps you turn the cheat sheet into something more useful for your own workflow. The best quantum gate reference is not the one with the most symbols. It is the one that matches the tasks you do repeatedly.

1. Add the views you actually need

Different readers need different representations. A beginner may need plain-English behavior and a one-line example. A researcher may want matrix forms, decompositions, and commutation relationships. A software engineer may care most about framework syntax and simulator behavior.

If you maintain your own notes, consider adding these columns:

  • Gate symbol
  • What it does in one sentence
  • Action on |0⟩ and |1⟩
  • Common use case
  • What beginners usually get wrong
  • Qiskit, Cirq, and PennyLane syntax
  • Hardware concern, if relevant

2. Group gates by job, not alphabetically

That usually makes a reference easier to scan. A practical grouping looks like this:

  • Bit-flip style: X
  • Phase style: Z, S, T
  • Bit-and-phase: Y
  • Superposition: H
  • Entangling and routing: CNOT, SWAP

That structure aligns better with how circuits are designed. You usually choose a gate because you need a type of transformation, not because you remember its letter first.

3. Match the framework to your learning path

If your goal is an IBM Quantum tutorial path, keep Qiskit examples front and center. If you are comparing frameworks, use parallel snippets. If you are focused on differentiable circuits and hybrid quantum AI workflows, PennyLane may deserve the most screen space.

For a framework selection guide, see Qiskit vs Cirq vs PennyLane for Beginners: Which Quantum Framework Should You Learn First?.

4. Add a “what changes if I measure now?” note

This is one of the best additions for quantum programming for beginners. For example:

  • After X on |0⟩, measurement becomes deterministic: you get 1.
  • After H on |0⟩, measurement becomes probabilistic: roughly 50/50 over repeated shots.
  • After Z on |0⟩, measurement is unchanged.
  • After Z on |+⟩, measurement behavior changes after later interference steps, even if it looks subtle immediately.

5. Keep hardware and simulator notes separate

A gate that is easy in a simulator may be relatively expensive on real hardware because of connectivity, noise, or decomposition into native operations. Keep a small note for that distinction rather than mixing it into the basic conceptual explanation.

If you are benchmarking locally before cloud runs, Best Quantum Simulators for Developers: Speed, Accuracy, and Framework Support is a useful companion read.

Examples

These short examples show how the gates combine in practice. The goal is not to teach entire algorithms, but to make the gate behavior feel concrete.

Example 1: Prepare a 1 from 0 using X

# Qiskit
from qiskit import QuantumCircuit
qc = QuantumCircuit(1, 1)
qc.x(0)
qc.measure(0, 0)

If the qubit starts in |0⟩, the X gate flips it to |1⟩. Repeated measurement should return 1 consistently in an ideal simulation.

Example 2: Create superposition with H

# Qiskit
from qiskit import QuantumCircuit
qc = QuantumCircuit(1, 1)
qc.h(0)
qc.measure(0, 0)

This is the standard first example in many quantum computing tutorials. You should see a roughly even split between 0 and 1 over many shots.

Example 3: Show phase matters with HZH

A classic identity is that H Z H behaves like X. That is a helpful reminder that basis changes can turn phase operations into bit-flip effects.

# Qiskit
qc.h(0)
qc.z(0)
qc.h(0)

This pattern is a good way to build intuition for why phase gates are not cosmetic.

Example 4: Make entanglement with H + CNOT

# Qiskit
from qiskit import QuantumCircuit
qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.measure([0, 1], [0, 1])

Starting from |00⟩, this can produce the Bell state (|00⟩ + |11⟩)/√2 before measurement. In ideal repeated runs, you should mostly see correlated outcomes: 00 and 11.

This pattern appears again and again in quantum circuits explained for beginners because it demonstrates superposition and entanglement in one compact circuit. It is also a useful starting point before studying variational methods such as those discussed in Variational Quantum Algorithms Explained: VQE, QAOA, and When They Matter.

Example 5: Route information with SWAP

Suppose the qubit you need to interact with is not adjacent on hardware. A compiler may insert SWAP operations to move states into place. Even if your original circuit does not mention SWAP, it can appear during transpilation or compilation.

That is why swap gate quantum searches often come from developers surprised by hardware execution differences. The gate itself is easy to understand; the reason it appears is often architectural.

Example 6: The same idea across frameworks

If you want a cross-framework check, here is a Bell-state pattern in all three libraries:

# Qiskit
qc.h(0)
qc.cx(0, 1)

# Cirq
circuit.append(cirq.H(qubits[0]))
circuit.append(cirq.CNOT(qubits[0], qubits[1]))

# PennyLane
qml.Hadamard(wires=0)
qml.CNOT(wires=[0, 1])

The syntax differs, but the conceptual sequence stays the same. That is one reason a framework-neutral gate reference remains useful even as tools change.

When to update

Revisit this cheat sheet whenever your workflow changes, not just when your memory fades. A stable concept can still benefit from updated examples, better organization, or framework-specific syntax changes.

Here are the main times to refresh your reference:

  • When your primary SDK changes. If you move from Qiskit to Cirq or PennyLane, update examples so you do not mentally translate every line.
  • When your learning stage changes. Beginners often need intuitive explanations. Later, you may want matrices, decompositions, and native gate mappings.
  • When you start using real hardware. Add notes for connectivity, transpilation, and gate cost. Cloud execution can make SWAP and two-qubit gates feel very different from simulator runs. A provider overview can help: IBM Quantum vs Amazon Braket vs Azure Quantum: Cloud Access Compared.
  • When best practices in your publishing or note-taking process change. If you maintain internal docs, onboarding material, or team tutorials, improve the structure so others can scan it quickly.

A practical next step is to create your own one-page version of this article with four columns: gate, plain-English meaning, common pitfall, and framework syntax. Then run through three circuits you use often and annotate which gates appear most. That simple exercise turns a static cheat sheet into a personal working reference.

If you are still setting up your environment, pair this article with the relevant installation guide: Qiskit Installation Guide, Cirq Installation Guide for Python Developers, or PennyLane Installation Guide.

The short version is this: X flips bits, Z flips phase, H creates superposition, S and T refine phase, CNOT creates conditional interaction and often entanglement, and SWAP moves states between qubits. If you can recognize those roles quickly, you can read a large share of beginner and intermediate circuits with much less friction.

Related Topics

#Quantum Gates#Cheat Sheet#Reference#Basics
S

Sharp Qbit Editorial

Senior SEO Editor

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.

2026-06-13T06:21:27.596Z