Curriculum / Quantum Foundations / The CNOT Gate

Lesson 15 of 17Code challengeFree+125 XP

The CNOT Gate

Learn the controlled-NOT gate, the key to entanglement.

The CNOT Gate

Controlled Operations

The CNOT (CX) gate is a two-qubit gate. It flips the target qubit only if the control qubit is |1⟩.

qc.cx(control, target)  # CNOT: flip target if control is 1

Truth Table

Written in the |q1 q0⟩ measurement-string convention from the previous lesson. Qubit 0 is the control, so the rightmost digit decides whether the target (left digit) flips:

  • |00⟩ → |00⟩ (control=0, no flip)
  • |01⟩ → |11⟩ (control=1, target flipped!)
  • |10⟩ → |10⟩ (control=0, no flip)
  • |11⟩ → |01⟩ (control=1, target flipped!)

Your Challenge

Create a 2-qubit circuit. Apply X to qubit 0 (to set it to |1⟩), then apply CNOT with qubit 0 as control and qubit 1 as target. Measure both qubits. You should see |11⟩ every time.

How this lesson works

A hands-on coding challenge. You write Qiskit-compatible Python in the browser editor, run it instantly via WebAssembly, watch the circuit and Bloch sphere react, and pass automatic output checks. The AI tutor Qubitus gives Socratic hints if you get stuck.

Part of: Quantum Foundations

Learn the basics: qubits, gates, superposition, and measurement.

Take this lesson free

Create a free account and start this lesson in your browser. No credit card, no installation.