Level 6 · Practitioner's Corner
Your First Qiskit Circuit
Reading about superposition and entanglement is one thing — actually running a quantum circuit and seeing the results is another. This walkthrough uses Qiskit, IBM's open-source quantum computing framework, to build and run one of the simplest meaningful circuits: creating a Bell state.
Step 1: Installation
Qiskit is a Python library. If you have Python installed, getting started takes one command:
pip install qiskit qiskit-aerThe qiskit-aer package includes a high-performance simulator, which is what we'll use here — no real quantum hardware access required for this first example.
Step 2: Build the circuit
We'll create the Bell state discussed throughout this site — two entangled qubits — using exactly the two gates described in our Hadamard Gate and CNOT Gate dictionary entries.
from qiskit import QuantumCircuit
# Create a circuit with 2 qubits and 2 classical bits for measurement
qc = QuantumCircuit(2, 2)
# Apply a Hadamard gate to qubit 0 — creates superposition
qc.h(0)
# Apply a CNOT gate: qubit 0 controls qubit 1 — creates entanglement
qc.cx(0, 1)
# Measure both qubits into the classical bits
qc.measure([0, 1], [0, 1])
print(qc)Running print(qc) shows a text-based circuit diagram — if you've read our Reading a Quantum Circuit Diagram article, this should already look familiar.
Step 3: Run it on a simulator
from qiskit_aer import AerSimulator
from qiskit import transpile
simulator = AerSimulator()
compiled_circuit = transpile(qc, simulator)
# Run the circuit 1000 times to build a statistical picture
result = simulator.run(compiled_circuit, shots=1000).result()
counts = result.get_counts()
print(counts)Step 4: Interpret the results
You should see output roughly like:
{'00': 498, '11': 502}Notice what's missing: you should see almost no '01' or '10' results. This is exactly the entanglement behavior described in our Bell State Measurement Simulator tool — both qubits always agree, even though each individual outcome is random. Roughly half the time both qubits read 0, and half the time both read 1, but they're never split between different values.
Why run it 1,000 times?
A single run of this circuit gives you one definite outcome (either '00' or '11') because of measurement collapse. To see the underlying probability distribution — and verify the entanglement is behaving as expected — you need to repeat the experiment many times, called "shots" in Qiskit terminology.
What's next
From here, a natural next step is trying this same circuit on real quantum hardware instead of a simulator — covered in our From Simulator to Real Hardware article — or exploring how a slightly larger circuit implements an actual algorithm, like the simplified Deutsch-Jozsa Algorithm.
Frequently Asked Questions
Do I need to understand the math to follow this tutorial?
Not deeply — this walkthrough is meant to build practical intuition. Reading our What is a Qubit? and Entanglement articles first will help the results make more sense, but you can run this code successfully without a deep mathematical background.
Why use a simulator instead of real hardware for this first example?
Simulators are instant, free, and (for small circuits like this one) produce results indistinguishable from real hardware, letting you focus on learning the code structure before dealing with the queue times and noise inherent to real quantum processors.
Continue learning