A quantum computing "hello world" — creating a Bell state with Qiskit.
HelloBell is the quantum analogue of printing "hello, world". It builds the simplest entangled state in quantum computing — the Bell state
using a Hadamard gate followed by a CNOT gate, then verifies entanglement via:
-
Expectation values —
$\langle ZZ \rangle = 1$ ,$\langle XX \rangle = 1$ ,$\langle ZI \rangle = \langle IZ \rangle = 0$ -
Measurement sampling — a 50/50 split between
$|00\rangle$ and$|11\rangle$
# Activate the virtual environment
source .venv/bin/activate
# Run the hello world
python hello_bell.pyExpected output:
Expectation values (ideal Bell state):
⟨ZZ⟩ = 1.0000 (should be 1.0000)
⟨ZI⟩ = 0.0000 (should be 0.0000)
⟨IZ⟩ = 0.0000 (should be 0.0000)
⟨XX⟩ = 1.0000 (should be 1.0000)
Measurement counts (1024 shots):
|00⟩: 542 (52.9%)
|11⟩: 482 (47.1%)
HelloBell/
├── hello_bell.py # Bell-state circuit + verification
├── .venv/ # Python virtual environment
├── .gitignore
└── README.md
| Gate | Qubit 0 | Qubit 1 | Effect |
|---|---|---|---|
| H | ─┤H├─ |
───── |
Creates superposition: $ |
| CX | ─■─── |
─┤X├─ |
CNOT flips q₁ when q₀ = $ |
The result is a maximally entangled two-qubit state — measuring one qubit instantly tells you the outcome of the other.
- Python 3.12+
- Qiskit 2.x (installed in
.venv/)
This project is for educational purposes. Feel free to use, share, and modify.