Your First Quantum Program: Build a Bell Pair with Qiskit
Build a tiny two-qubit Bell-state circuit in Qiskit, run it on a simulator, and learn what its measurement results do - and do not - tell you.
Quantum computing is not simply a faster version of an ordinary computer. It uses different rules to represent and process information. In this first hands-on example, we will build a tiny two-qubit circuit that produces a Bell pair - a simple example of entanglement - and inspect what happens when we measure it.
This circuit is a learning exercise, not a useful speedup or a demonstration that quantum computers try every answer at once. Its value is that it lets us see the basic rhythm of quantum programming: prepare qubits, apply gates, measure, and interpret repeated results.
A qubit is not a magic bit
A classical bit stores either 0 or 1. A qubit can be prepared in a state that gives different probabilities for those outcomes when measured. In the simplest notation, its state is written as α|0⟩ + β|1⟩, where the measurement probabilities are |α|² and |β|², and those probabilities add to 1.
That does not mean a measurement prints both 0 and 1. A single measurement in the usual computational basis returns one classical result: 0 or 1. Quantum algorithms use operations on the state - including interference between amplitudes - to shape the probabilities of later results. Measurement gives us samples, not a readable list of every possibility.
Build a Bell pair
We will start with two qubits, both in state |0⟩. A Hadamard (H) gate puts the first qubit into an equal superposition. Then a controlled-NOT (CX) gate uses qubit 0 as its control and qubit 1 as its target: when the control is 1, the target flips. Together, these gates prepare the Bell state (|00⟩ + |11⟩)/√2.
Install Qiskit and its simulator in a terminal:
python -m pip install qiskit qiskit-aer
Then run this Python program:
from qiskit import QuantumCircuit
from qiskit_aer import AerSimulator
# Prepare two qubits in |00⟩.
circuit = QuantumCircuit(2)
# Put qubit 0 into superposition, then entangle it with qubit 1.
circuit.h(0)
circuit.cx(0, 1)
# Convert the quantum outcomes into classical bit strings.
circuit.measure_all()
simulator = AerSimulator()
result = simulator.run(circuit, shots=1000).result()
print(result.get_counts())
You should see counts for 00 and 11, with roughly similar totals - for example, about 500 of each in 1,000 shots. The exact counts vary from run to run. A shot is one execution of the circuit; the simulator repeats it many times so we can estimate the outcome probabilities. On an ideal, noise-free simulation, the other two strings, 01 and 10, should not appear.
What the results mean
The key pattern is correlation: when the circuit is measured, the two bits match. The state prepared by the H and CX gates is entangled in the ideal mathematical model, and the correlation is why the Bell pair is a useful first example.
There is an important experimental caveat: seeing only 00 and 11 in this one measurement basis does not, by itself, prove that a physical device produced entanglement. A classical process that randomly emits 00 or 11 could produce the same histogram. Demonstrating entanglement in an experiment requires additional measurements or a suitable entanglement test. Real quantum hardware can also produce occasional 01 or 10 results because gates and measurements are imperfect.
For a first experiment, try changing shots=1000 to shots=100 and compare the totals. Then remove circuit.cx(0, 1) and run the program again: qubit 0 will still be sampled as 0 or 1, while qubit 1 stays at 0, so the pair no longer has the same entangled state.
The goal is not to make a quantum computer do something magical. It is to learn how gates prepare a state, how measurement turns that state into ordinary data, and why repeated runs matter. Once those ideas feel familiar, bigger circuits become much easier to reason about.
For a guided walkthrough of a first quantum circuit, see IBM Quantum's beginner tutorial. For a broader introduction to qubits, superposition, and the limits of popular “quantum parallelism” claims, see NIST's explanation of quantum computing.