How to Build Your First Quantum Circuit in Qiskit: From Bell State to Measurement
tutorialQiskitcodingcircuits

How to Build Your First Quantum Circuit in Qiskit: From Bell State to Measurement

DDaniel Mercer
2026-04-26
17 min read
Advertisement

Learn how to build and run your first Bell-state quantum circuit in Qiskit, locally and on IBM Quantum.

If you’re a software engineer, the fastest way to understand quantum programming is to stop reading abstract theory and build a tiny working program. In this quantum innovations-driven field, the best entry point is a two-qubit circuit that creates a Bell state, then measures it locally or on IBM Quantum. This guide gives you that minimum viable workflow, while also showing you how the concepts map to real engineering practice, simulator behavior, and cloud execution. If you want broader context on the hardware and why the ecosystem matters, see quantum computing fundamentals and the market overview in Bain’s 2025 quantum report.

1) What You’re Actually Building

Start with the smallest useful quantum program

A Bell state circuit is the “hello world” of quantum programming because it demonstrates the three concepts every engineer needs first: superposition, entanglement, and measurement. The circuit uses a Hadamard gate to place one qubit into an even probability blend of 0 and 1, then a CNOT gate to entangle a second qubit with the first. After that, measurement collapses the quantum state into classical bits that you can inspect like ordinary program output. For a practical setup mindset, it helps to think of the circuit as a reproducible experiment, similar to evaluating a device with a quantum computing kit before moving to a larger platform.

Why engineers should care about Bell states first

Bell states are not useful because they solve a business problem directly; they are useful because they teach you how quantum state evolves under gates and how measurement destroys that state. That distinction matters, because quantum programs are not just “faster Python.” They are workflows where you carefully shape probabilities, run many shots, and aggregate counts instead of expecting one deterministic result. This is part of why the current industry emphasis is still on experimentation, tooling, and hybrid workflows, as noted in Bain’s quantum computing report and in broader discussions of near-term use cases.

Local first, cloud second

For first-time builders, local simulation is the best path because it removes noise from the learning process. Once you understand the statevector and measurement counts on your machine, you can move the same circuit to IBM Quantum and compare simulator output with real hardware behavior. This local-to-cloud progression is similar to how developers prototype in one environment and then promote the same code to staging or production, an approach also discussed in practical tooling articles like remote development environments and AI search visibility, where reproducibility and discoverability matter.

2) Prerequisites and Setup

Install Python, Qiskit, and a clean virtual environment

The easiest way to get started is with Python 3.10+ and a dedicated virtual environment. Use one environment per project so your Qiskit version, simulator dependencies, and IBM Runtime packages don’t clash with other work. This is standard software hygiene, but it becomes especially important in quantum because package updates can affect transpilation behavior and backend compatibility. If you’re also planning your learning path, it’s worth reviewing developer upskilling strategies so your quantum work can be framed as a portfolio-ready engineering project.

Minimal install commands

Install Qiskit and the IBM provider packages. Exact package names can evolve over time, but the goal is always the same: core circuit-building libraries plus a simulator or backend access package. A typical setup might look like this:

python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install qiskit qiskit-aer qiskit-ibm-runtime

From there, verify the install by opening Python and importing the main modules. You’re looking for a clean import path, not a full benchmark. If your environment is stable, you can proceed confidently to circuit construction.

Why the toolchain matters

Quantum SDKs are still fragmented compared with mainstream software stacks, so picking one coherent setup matters more than chasing every framework at once. For a broader view of the ecosystem and what to expect from commercial adoption, pair this tutorial with AI’s future through quantum innovations and the hardware context in quantum computing. If you want to see what a broader starter ecosystem can look like, this practical guide to quantum kits gives a useful analogy for what’s essential versus optional.

3) Build the Bell State Circuit Step by Step

Create the circuit and allocate qubits

In Qiskit, you begin by creating a quantum circuit with two qubits and two classical bits. The classical bits are where the measurement results will land after the quantum state is collapsed. Think of this as defining both the experiment and the reporting layer at the same time, which keeps the circuit easy to read and debug. Here’s the core setup:

from qiskit import QuantumCircuit

qc = QuantumCircuit(2, 2)

That single object becomes the container for all your instructions. In larger projects, you’ll build many such circuits and then batch them for simulation or cloud execution. But for now, keep it tiny and inspectable.

Apply the Hadamard gate

The first key operation is the Hadamard gate on qubit 0. This gate creates superposition, which means qubit 0 no longer behaves like a classical bit with a single definite value. Instead, it becomes a probabilistic combination of states until measurement occurs. In practical terms, this is the moment when the circuit stops being a simple classical register and starts behaving like a quantum experiment.

qc.h(0)

You can think of the Hadamard as an “either/or splitter” for the amplitude of the qubit. On a simulator, this won’t give you a visible output yet, but it prepares the circuit for entanglement. If you’re new to the gate model, revisit the underlying concepts in quantum computing fundamentals and remember that the state is manipulated mathematically before it is observed.

Apply the CNOT gate and create entanglement

The next step is the controlled-NOT gate, commonly written as CNOT or CX, with qubit 0 as control and qubit 1 as target. This gate copies the control qubit’s state into the target in a quantum sense, but only through the rules of unitary evolution, not classical copying. After the CNOT, the two qubits are entangled, meaning the joint state cannot be described independently anymore. That correlation is the defining feature of a Bell state.

qc.cx(0, 1)

For software engineers, the easiest mental model is “dependency with no classical equivalent.” If qubit 0 measures as 0, qubit 1 will match; if qubit 0 measures as 1, qubit 1 will also match. The individual bits remain random, but the pair is perfectly correlated. That is the simplest observable signature of entanglement and the reason this circuit is such a foundational test.

4) Measure, Run, and Read the Results

Add measurement instructions

Measurement is where quantum information becomes classical data. In Qiskit, you map qubits to classical bits explicitly, which is a helpful reminder that measurement is not a passive read; it is an operation that changes the system. For our Bell circuit, measure both qubits into both classical bits:

qc.measure([0, 1], [0, 1])

Once you add measurement, the circuit is no longer just a mathematical object. It becomes a runnable experiment. This is also why quantum programming has a stronger testing mindset than many developers expect: you often validate distributions across many shots rather than one exact output.

Draw the circuit before execution

Always inspect the circuit diagram before you run it. This is the quantum equivalent of checking a DAG or reviewing an infrastructure plan before deployment. A quick visual check can reveal swapped qubits, missing measurements, or an incorrectly oriented entangling gate. If you like working visually, this stage is also where you can compare your circuit against broader engineering workflows discussed in high-trust live workflow design, where clarity and auditability matter.

print(qc.draw())

The diagram should show the Hadamard on the first qubit, the CNOT connecting qubit 0 to qubit 1, and the measurements at the end. If that looks right, you’re ready to simulate.

Run on a simulator and inspect counts

To run locally, use Aer or another simulator backend. Execute the circuit with multiple shots, commonly 1024, so you can see the measurement distribution. Because this Bell state ideally produces only two outcomes, you should get mostly or entirely 00 and 11, with roughly equal probability on a noiseless simulator. Here is a compact example:

from qiskit_aer import AerSimulator
from qiskit import transpile

simulator = AerSimulator()
compiled = transpile(qc, simulator)
result = simulator.run(compiled, shots=1024).result()
counts = result.get_counts()
print(counts)

On a good simulator, the output often looks like {'00': 512, '11': 512} or something close to that. The exact split varies due to randomness, but the absence of 01 and 10 is the important result in an ideal Bell-state experiment.

5) Interpret the Physics Like an Engineer

Superposition is not “both values at once” in a classical sense

One common mistake is to describe superposition as a qubit literally “being 0 and 1 at the same time” in the same way a software variable might hold two values. That shorthand is useful for intuition but incomplete. A more accurate view is that the qubit has amplitudes, and those amplitudes determine the probability of each measurement outcome. The simulator tracks those amplitudes exactly, while real hardware can introduce noise that distorts them.

Entanglement creates correlations, not telepathy

Entanglement can look mysterious, but in code it behaves like a system-wide state dependency with non-classical rules. The Bell circuit ensures that the two qubits share a joint state, so measuring one gives you immediate information about the other. That does not mean information is transmitted faster than light; it means the state was prepared in a correlated way. If you want to explore how this fits into practical quantum roadmaps, the industry view in Bain’s technology report is a useful complement.

Why shots matter

Quantum programs are typically run many times because one measurement is inherently probabilistic. “Shots” are repeated executions of the same circuit, and the resulting histogram is what you analyze. In the Bell-state example, shots help you confirm that the ideal probabilities are concentrated on the correlated pairs. This is one of the biggest mindset shifts for developers coming from classical systems, where a single run is usually enough to validate behavior.

6) A Full Working Example You Can Copy

Complete local Bell state script

Here is a clean, minimal script you can run locally. It creates the Bell state, draws the circuit, executes it on a simulator, and prints the results. Keep this as your reference template while learning the syntax and structure of Qiskit programs.

from qiskit import QuantumCircuit, transpile
from qiskit_aer import AerSimulator

# 1) Create a 2-qubit, 2-classical-bit circuit
qc = QuantumCircuit(2, 2)

# 2) Put qubit 0 into superposition
qc.h(0)

# 3) Entangle qubit 0 with qubit 1
qc.cx(0, 1)

# 4) Measure both qubits
qc.measure([0, 1], [0, 1])

# 5) Inspect the circuit
print(qc.draw())

# 6) Simulate
simulator = AerSimulator()
compiled = transpile(qc, simulator)
result = simulator.run(compiled, shots=1024).result()
counts = result.get_counts()
print(counts)

If you want to extend this into a project artifact, wrap it in a notebook or package it as a small CLI. That turns a learning exercise into a demonstrable engineering sample, which is especially valuable if you are documenting your work for recruiters or collaborators. For career framing and developer portfolio strategy, see AI-proof your developer resume.

Expected output and how to verify it

On a noiseless simulator, the counts should cluster around 00 and 11. If you see 01 or 10, that usually means there is a bug in gate order, qubit indexing, or measurement mapping. Developers often assume any odd output means “quantum randomness,” but in a first tutorial the most likely cause is a coding mistake. Debug the circuit visually first, then inspect transpilation and backend details if the logic is correct but the results remain unexpected.

7) Run the Same Circuit on IBM Quantum

Why move from simulator to hardware

Running your circuit on IBM Quantum lets you observe the gap between ideal simulation and physical execution. Real devices introduce noise, decoherence, and gate errors, which means the counts may no longer look perfectly split between 00 and 11. That difference is not a failure; it is the reality of current quantum hardware, and understanding it is essential if you want to move beyond demos. This is one reason the field remains promising but experimental, as reflected in the broader perspective from quantum computing and industry outlooks like Bain’s report.

Authenticate and choose a backend

IBM Quantum access usually requires an account and an API token, which you store securely in your local environment or secret manager. Once authenticated, you can list available backends and choose a device with enough qubits and acceptable queue time. For beginners, the priority should be simplicity: start with the cloud simulator or a small device instead of trying to optimize for the newest hardware. The same principle applies in other engineering workflows, such as comparing tooling alternatives before committing to production use.

Understand noise and transpilation

Before sending a circuit to hardware, Qiskit transpiles it into a form the selected backend can execute. That can change gate decomposition, depth, and qubit placement, all of which affect fidelity. This is why a circuit that looks simple on paper may behave differently on real hardware. If you want to deepen your understanding of how quantum devices are packaged and presented to learners, the practical perspective in What’s inside a quantum computing kit is a useful bridge between theory and hands-on work.

8) Common Mistakes and How to Debug Them

Mixing up qubit and classical bit order

One of the most common beginner mistakes is confusing the order of bits in the output. Qiskit’s display and count strings can be counterintuitive because classical bit order may appear reversed relative to the physical qubits. If your output looks wrong, verify which qubit maps to which classical bit and check the diagram rather than assuming the counts are wrong. This kind of precise data handling is similar to the discipline needed in responsible data management.

Forgetting measurement or running too few shots

Without measurement, you cannot obtain classical counts. Without enough shots, your histogram may be too noisy to interpret. Both errors are easy to make when you first focus on the gate logic and forget the execution layer. A good habit is to treat “measure, run, inspect” as a fixed checklist for every circuit you build.

Assuming real hardware behaves like a simulator

Real devices are noisy, and that noise grows as the circuit gets deeper or the device gets busier. Your first Bell state may still work reasonably well on hardware, but it will almost never look as perfect as the ideal simulator. That gap is exactly why error mitigation, calibration, and hardware-aware compilation are such important parts of practical quantum computing. In the wider tech landscape, this sort of operational reality is also why leaders are paying attention to skills planning and readiness in reports like Bain’s 2025 outlook.

9) Comparison Table: Simulator vs Hardware vs Learning Focus

The table below summarizes the practical differences you’ll see as you move from your laptop to IBM Quantum. It’s meant to help you decide what to test at each stage and what result quality to expect.

EnvironmentBest ForExpected Bell OutputMain AdvantageMain Caveat
Local statevector simulatorLearning gates and amplitudesIdeal counts near 00 and 11Deterministic debuggingNo hardware noise
Local shot-based simulatorPracticing measurement statisticsRandomized but balanced countsMimics real runsStill noiseless unless modeled
IBM Quantum cloud simulatorTesting cloud workflowIdeal or near-ideal countsBackend compatibilityQueue and account setup
Small IBM Quantum hardware backendExperiencing real-device noiseMostly 00 and 11, with some errorsAuthentic executionNoise, queue time, transpilation effects
Deeper multi-gate circuitsExploring advanced workflowsHarder to predictBuilds real skillRequires stronger debugging discipline

10) Your Next Steps After the Bell State

Extend the circuit deliberately

Once you can build and run a Bell state, the next step is not to jump directly into advanced algorithms. Instead, change one thing at a time: swap the target qubit, add another gate, or remove measurement and inspect the statevector. Small experiments help you build intuition faster than trying to memorize a whole library of algorithms. If you want a broader tour of adjacent technologies and career pathways, AI and quantum innovation trends are a good companion read.

Try a mini lab roadmap

A practical learning sequence for engineers looks like this: first, recreate the Bell state; second, inspect the circuit diagram; third, compare simulator counts to hardware counts; fourth, vary the number of shots; fifth, add a third qubit and see how the logic changes. That sequence builds real intuition without overwhelming you. If you want to understand how quantum learning resources fit into a larger skill stack, see also developer resume strategy and modern development workflows.

Think in terms of reusable engineering assets

Your goal is not just to “learn quantum”; it is to create reusable, testable code that you can revisit later. Save your circuit script, version it in Git, and annotate the expected output. That makes your work easier to compare against future experiments, whether you are using a simulator, IBM Quantum, or a different SDK. As the market matures, having a clean codebase and a habit of reproducible experiments will matter more than collecting isolated tutorial results.

FAQ

What is the smallest useful Qiskit quantum circuit for a beginner?

A two-qubit Bell state circuit is the best starting point. It uses a Hadamard gate, a CNOT gate, and measurement, which together show superposition, entanglement, and classical readout in one compact example.

Why do I need to run the circuit many times?

Quantum measurements are probabilistic, so one execution is not enough to understand the behavior of the circuit. Multiple shots let you build a histogram of outcomes and verify whether the circuit is producing the expected distribution.

Why does my output differ between simulator and IBM Quantum?

Simulators are idealized, while real hardware has noise, decoherence, and calibration limits. Those differences are expected and are part of why hardware execution is valuable for learning.

Do I need advanced math to build my first circuit?

No. You can learn the operational workflow first: create the circuit, apply gates, measure, and analyze counts. Deeper linear algebra helps later, but it is not required to run your first working program.

What should I do after Bell states?

Try single-qubit experiments, add a third qubit, inspect statevectors, and compare different backends. After that, you can move into basic algorithms and noise-aware execution.

Final Takeaway

If you can build a Bell state in Qiskit, you already understand the core execution model of beginner quantum programming. You know how to create a circuit, apply the Hadamard and CNOT gates, add measurement, and verify the result locally before moving to IBM Quantum. That is enough to start learning productively, because it gives you a repeatable workflow rather than a vague concept list. Keep this tutorial as your baseline, then expand it into more complex experiments as your confidence grows.

For more context on how this field is evolving, revisit the broader perspective in quantum computing, the industry outlook in Bain’s technology report, and the practical tooling mindset reflected in hands-on quantum kit guides. The winning strategy is simple: keep the circuit small, keep the output measurable, and keep iterating.

Advertisement

Related Topics

#tutorial#Qiskit#coding#circuits
D

Daniel Mercer

Senior Quantum Content Strategist

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.

Advertisement
2026-04-26T02:58:22.546Z