LEARN

Your First Quantum Circuit: Qiskit for People Who Already Write Python

Build a Bell state in Qiskit and find out why its output is a histogram instead of an answer.

V

Vinodhkumar Gunasekaran

Sep 20, 2026 · 3 min read

Your First Quantum Circuit: Qiskit for People Who Already Write Python

If you write Python, you already know enough syntax to write a quantum program. The harder adjustment is a habit you have never had to question, that the same code on the same input returns the same answer. A quantum program breaks it on the first run.

Setting up

You need Python 3.10 or later. Python 3.8 reached end of life in October 2024, and much of the Qiskit ecosystem now treats 3.10 as the minimum.

python -m venv quantum-env
source quantum-env/bin/activate
pip install qiskit qiskit-aer qiskit-ibm-runtime

The qiskit package is the circuit-building core, qiskit-aer runs simulations on your own machine, and qiskit-ibm-runtime connects to IBM's hardware once you want it. Start with the simulator. Real devices come with queues, and with noise you don't yet have the vocabulary to read.

The circuit

from qiskit import QuantumCircuit, transpile
from qiskit_aer import AerSimulator

qc = QuantumCircuit(2, 2)
qc.h(0)  # Hadamard: put qubit 0 into superposition
qc.cx(0, 1)  # CNOT: entangle qubit 1 with qubit 0
qc.measure([0, 1], [0, 1])
print(qc.draw())

The Hadamard gate puts qubit 0 into a superposition of |0⟩ and |1⟩. CNOT then entangles qubit 1 with it, and the pair ends up in the Bell state (|00⟩ + |11⟩)/√2. The last line measures both qubits into classical bits.

Running it

simulator = AerSimulator()
circuit = transpile(qc, simulator)
result = simulator.run(circuit, shots=1024).result()
counts = result.get_counts()
print(counts)
# {'00': 512, '11': 512}, approximately

The transpile call rewrites your circuit using only the operations the backend supports. On a circuit this small it changes almost nothing. Keep it anyway, since on real hardware it does real work, and the habit is easier to build on your first program than your fiftieth.

Look at shots=1024. The simulator runs the circuit 1,024 times and counts how often each outcome appears, because one run on its own tells you almost nothing.

What the counts are telling you

Roughly half the shots come back 00 and roughly half come back 11. Neither 01 nor 10 ever shows up. In data terms, you have two variables that each behave like a fair coin and always agree with each other.

Two classical devices that share a pre-agreed random bit could print this exact table, so the table alone proves nothing exotic. The difference appears when you measure the two qubits along different axes from each other. As the angle between the two measurements changes, the rate at which the qubits agree follows a curve that no pre-agreed classical strategy can reproduce. Bell's theorem is the proof of that gap, and the gap is why entanglement counts as a resource for quantum computing rather than just a strong correlation.

This changes how you test code. A unit test can't check for one exact output, so it checks that the distribution looks right, and you start asking how many shots you need before you trust a result. If you have run Monte Carlo simulations, you already have half of this intuition.

The other half, interference, will be new. Amplitudes can cancel each other out, and quantum algorithms use that cancellation to suppress wrong answers instead of merely sampling among them.

What this doesn't do yet

The field's marketing runs ahead of its hardware. This circuit does nothing useful, and neither does anything you would run on today's devices as a production workload. Current processors are noisy enough that ordinary classical computers still win on nearly every problem anyone actually needs solved.

That is still a reason to start now. Retraining your intuition takes the longest, and better hardware won't make it any quicker.

Where to go next

IBM's free courses at quantum.cloud.ibm.com/learning are the best next step. Try one experiment first: build the same Bell state, then add a gate so that one qubit is measured along a different axis from the other, and watch the agreement between them change. It is the quickest way to see the effect Bell's theorem is about.

Run the code

Every snippet here lives in the TowardsQuantum/studies repository, pinned to the package versions it was tested against.

git clone https://github.com/TowardsQuantum/studies
cd studies/getting-started-with-qiskit
pip install -r requirements.txt
python bell_state.py

github.com/TowardsQuantum/studies. Issues and corrections are welcome.

The views expressed in this article are the author's own and do not represent the positions of their employer or any affiliated organization.

V

Written by

Vinodhkumar Gunasekaran

Principal, Global Innovation & Analytics at Circana.