skip to content
Ivan's wiki
Site Tools
Search
Tools
Show pagesource
Backlinks
Recent Changes
Media Manager
Sitemap
>
Recent Changes
Media Manager
Sitemap
qiskit-quantum-circuits
This page is read only. You can view the source, but not change it.
# Quantum circuits **Quantum circuits** are the fundamental way to describe quantum computations in Qiskit—an ordered sequence of operations applied to qubits. A circuit specifies which gates to apply, in what order, on which qubits, and where to measure. Think of it like assembly code: abstract and portable, executable on any backend that supports the required gate set. In Qiskit, a `QuantumCircuit` object holds qubits (quantum registers) and classical bits (classical registers). Qubits hold quantum state; classical bits hold measurement results. Gates modify qubit state; measurements collapse qubits and write results to classical bits. ```python from qiskit import QuantumCircuit # Create a 3-qubit, 3-bit circuit qc = QuantumCircuit(3, 3) # Apply gates qc.h(0) # Hadamard on qubit 0 qc.cx(0, 1) # CNOT: qubit 0 controls qubit 1 qc.rz(0.5, 2) # RZ rotation on qubit 2 # Measure all qubits qc.measure([0, 1, 2], [0, 1, 2]) # Draw the circuit print(qc.draw()) ``` Circuits are abstract—they don't execute until you send them to a backend (simulator or hardware). This abstraction lets you design once and run on different backends. Before execution, [transpilation](/qiskit-transpilation) adapts your circuit to the backend's native gates and qubit topology. ## Circuit construction Gates can be chained, and Qiskit provides hundreds: single-qubit gates (H, X, Y, Z, S, T, RX, RY, RZ), two-qubit gates (CNOT, CZ, SWAP), and multi-qubit gates (Toffoli, controlled operations). Use the circuit's methods to add gates: `qc.h(0)`, `qc.cx(0, 1)`, etc. You can also inspect and manipulate circuits: get the number of qubits/bits, decompose gates, remove or insert operations, and compose smaller circuits together. ```python # Get circuit info print(qc.num_qubits) # 3 print(qc.num_clbits) # 3 print(qc.depth()) # Circuit depth (longest qubit path) # Compose two circuits qc2 = QuantumCircuit(3, 3) qc2.h([0, 1, 2]) combined = qc.compose(qc2) ``` ## Parameterized circuits [Parameterized circuits](/qiskit-parameterized-circuits) replace fixed rotation angles with parameters, useful for [variational algorithms](/qiskit-variational-algorithms). Define parameters once, then bind them to different values for each evaluation without rebuilding the circuit.
Page Tools
Show pagesource
Backlinks
Back to top