Lab 01 — Your first quantum circuit
In this lab you will set up your machine, install Qiskit, and run a genuine quantum circuit on a simulator. By the final step, a qubit will do something no classical bit can: measure as 0 and 1 across many runs.
Download notebook (.ipynb)Open it in VS Code or Jupyter — every code cell below runs as-is.
Get Python
Everything in this lab runs on Python. The easiest path is the Anaconda distribution (it bundles Python plus the scientific tools), or grab Python directly from python.org — version 3.10 or newer.
python --version # you want to see: Python 3.10 (or newer)
Make a clean room
Quantum libraries pull in a lot of dependencies. Keep them isolated in their own environment so they never fight with your system Python:
conda create -n qc-lab python=3.11 conda activate qc-lab
No conda? The built-in alternative works the same way:
python -m venv qc-lab source qc-lab/bin/activate # Windows: qc-lab\Scripts\activate
(qc-lab).Install Jupyter
Jupyter notebooks let you run code cell-by-cell and see results instantly — ideal for experimenting with circuits:
pip install notebook jupyter --version
jupyter notebook — a browser tab should open.Install the quantum stack
In a notebook cell (or the terminal), install Qiskit and its simulator:
pip install qiskit qiskit-aer
Verify it took:
import qiskit print(qiskit.__version__)
2.x prints with no errors.--prefer-binary to the pip command and retry.Python warm-up (3 minutes)
Qiskit is a Python library, so let's wake up the three constructs you'll use constantly:
# variables + f-strings
shots = 1000
print(f"Running {shots} shots")
# loops
total = 0
for i in range(10):
total += i
print(total) # 45
# functions
def greet(name):
return f"Hello, {name}!"
print(greet("qubit")) Running 1000 shots, 45, Hello, qubit!.Build your first circuit
A quantum circuit has qubits (the quantum registers) and classical bits (where measurement results land). One qubit, one classical bit, one measurement:
from qiskit import QuantumCircuit qc = QuantumCircuit(1, 1) # 1 qubit, 1 classical bit qc.measure(0, 0) # measure qubit 0 -> bit 0 print(qc.draw())
M) connecting the qubit line to the classical line.Run it on a simulator
No quantum hardware needed — AerSimulator mimics an ideal quantum computer on your laptop.
Run the circuit 1,000 times and count the outcomes:
from qiskit_aer import AerSimulator sim = AerSimulator() job = sim.run(qc, shots=1000) counts = job.result().get_counts() print(counts)
{'0': 1000} — a qubit in state |0⟩ measures 0 every single time. So far, boringly classical. That changes now.Your turn: flip the qubit
The X gate is the quantum NOT — it flips |0⟩ to |1⟩. Add it before the measurement. Before running: predict the counts out loud.
qc2 = QuantumCircuit(1, 1) qc2.x(0) # flip |0> -> |1> qc2.measure(0, 0) counts2 = sim.run(qc2, shots=1000).result().get_counts() print(counts2)
{'1': 1000} — every shot is 1, exactly as you predicted. Prediction matched? You're thinking like a quantum programmer.Your turn: superposition
The H (Hadamard) gate puts |0⟩ into a superposition — neither 0 nor 1 until measured. Predict first, then run:
qc3 = QuantumCircuit(1, 1) qc3.h(0) # |0> -> superposition qc3.measure(0, 0) counts3 = sim.run(qc3, shots=1000).result().get_counts() print(counts3)
{'0': 498, '1': 502} — roughly half and half. It will never be exactly 500/500, and it will differ every run. That randomness is not a bug: it is quantum mechanics, observed.{'0': 1000}, the H gate went after the measurement — order matters. Gates apply top to bottom.Debrief — what did you prove?
With three tiny circuits you verified the core facts of quantum computing: a qubit starts at |0⟩, gates transform its state, measurement collapses it to classical bits, and superposition produces genuinely random outcomes. The simulator agreed with the theory — 1,000 shots at a time.
Next: two qubits, where things get entangled — that's Lab 02. To understand why the H gate does what it does, visit the qubit lesson.