← Quantum Store · Guides · Lessons · Glossary · About · Türkçe
Guide · Hakan Erdoğan
Getting started with quantum programming: your first Qiskit circuit
How to start quantum programming: installing Qiskit, writing your first quantum circuit (a Bell state) and what to learn next. A step-by-step guide for Python developers.
What does a quantum program look like?
A quantum program is a quantum circuit: gates applied to qubits followed by measurements. In Python you create a circuit object, add gates in order, run the circuit many times on a simulator or a real quantum processor, and look at the counts of the measurement results.
1. Install Qiskit
Python 3.10 or newer is enough. Installing into a separate virtual environment is recommended:
python -m venv quantum
# Windows: quantum\Scripts\activate macOS/Linux: source quantum/bin/activate
pip install qiskit
2. Your first circuit: two entangled qubits (Bell state)
The program below creates two qubits, puts the first one into superposition with a Hadamard (H) gate, entangles the second with it using a CNOT gate and measures both. The circuit is run 1000 times.
from qiskit import QuantumCircuit
from qiskit.primitives import StatevectorSampler
qc = QuantumCircuit(2)
qc.h(0) # qubit 0: superposition
qc.cx(0, 1) # CNOT: entangle qubit 1 with qubit 0
qc.measure_all()
result = StatevectorSampler().run([qc], shots=1000).result()
print(result[0].data.meas.get_counts())
3. Read the result
The output is a count such as {'00': 507, '11': 493}; the numbers change a little on every run. 01 and 10 never appear: the two qubits always agree. That is the signature of entanglement. Each qubit on its own looks random, yet the two are linked.
Delete the qc.h(0) line and you always get 00; replace it with qc.x(0) and you always get 11. Changing gates and predicting the result is the fastest way to build quantum intuition.
4. Next steps
Try noise: on real hardware qubits make errors. With Qiskit Aer you can add a noise model and watch the same circuit’s result degrade.
Move on to algorithms: Deutsch–Jozsa, Bernstein–Vazirani and Grover are short algorithms that show how interference gives a speed-up. After them come quantum teleportation, a small Shor example that factors 15, and optimisation with QAOA.
Real hardware: with an IBM Quantum account you can send your circuit to a real processor on the free tier. Cirq, PennyLane, TKET and Amazon Braket offer the same ideas in other ecosystems.
Every Quantum Store package ships tested example code; the package pages list installation steps and the example scripts.
Frequently asked questions
Which language is used for quantum programming?
Mostly Python. Qiskit, Cirq, PennyLane and TKET are Python libraries. There are also languages such as Microsoft’s Q# and circuit description languages such as OpenQASM.
Is Qiskit free?
Yes. Qiskit is open-source software under the Apache 2.0 licence; you can run it without limits on a simulator and on real hardware through IBM Quantum’s free tier.
How long does it take to learn quantum programming?
You can learn the basic concepts and write your first circuits in a few hours. Becoming comfortable with algorithms takes a few days of practice.
Concepts in this guide
- Quantum circuit · A quantum circuit is a quantum program made of gates applied to qubits in order, followed by measurements.
- Quantum gate · A quantum gate is a basic operation that reversibly changes the state of one or more qubits; quantum programs are sequences of gates.
- Hadamard gate (H) · The Hadamard gate is a single-qubit quantum gate that turns a qubit in |0⟩ into an equal superposition of 0 and 1.
- CNOT gate · The CNOT (controlled-NOT) gate is a two-qubit gate that flips the target qubit when the control qubit is 1; it is the basic tool for creating entanglement.
- Bell state · A Bell state is one of four special states in which two qubits are entangled in the simplest and strongest way; the best known gives only 00 or 11 when measured.
- Qiskit · Qiskit is IBM’s open-source Python library for quantum programming; it lets you build circuits, run them on simulators and send them to IBM quantum computers.
- Grover’s algorithm · Grover’s algorithm finds a marked item among N unsorted items in about √N steps, a quadratic speed-up over classical search.
Full quantum computing glossary →