# Measure qubits

To get information about a qubit's state, you can *measure* it onto a classical bit. In Qiskit, measurements are performed in the computational basis, that is, the single-qubit Pauli-$Z$ basis. Therefore, a measurement yields 0 or 1, depending on the overlap with the Pauli-$Z$ eigenstates $|0\rangle$ and $|1\rangle$:

## Apply a measurement to a circuit

There are several ways to apply measurements to a circuit:

`QuantumCircuit.measure`

method

Use the `measure`

method to measure a `QuantumCircuit`

.

Examples:

```
from qiskit import QuantumCircuit
qc = QuantumCircuit(5, 5)
qc.x(0)
qc.x(1)
qc.x(4)
qc.measure(range(5), range(5)) # Measures all qubits into the corresponding clbit.
```

```
from qiskit import QuantumCircuit
qc = QuantumCircuit(3, 1)
qc.x([0, 2])
qc.measure(1, 0) # Measure qubit 1 into the classical bit 0.
```

`Measure`

class

The Qiskit Measure class measures the specified qubits.

```
from qiskit.circuit import Measure
....
qc.append(Measure(), [0], [0]) # measure qubit 0 into clbit 0
```

`QuantumCircuit.measure_all`

method

To measure all qubits into the corresponding classical bits, use the `measure_all`

method. By default, this method adds new classical bits in a `ClassicalRegister`

to store these measurements.

```
from qiskit import QuantumCircuit
qc = QuantumCircuit(3, 1)
qc.x([0, 2])
qc.measure_all() # Measure all qubits.
```

`QuantumCircuit.measure_active`

method

To measure all qubits that are not idle, use the `measure_active`

method. This method creates a new `ClassicalRegister`

with a size equal to the number of non-idle qubits being measured.

```
from qiskit import QuantumCircuit
qc = QuantumCircuit(3, 1)
qc.x([0, 2])
qc.measure_active() # Measure qubits that are not idle, i.e., qubits 0 and 2.
```

- Circuits that contain operations
*after*a measurement are called dynamic circuits. Not all QPUs or simulators support these. - There must be at least one classical register in order to use measurements.
- The Sampler primitive requires circuit measurements. You can add circuit measurements with the Estimator primitive, but they are ignored.

## Next steps

`Measure`

class`measure_all`

method`measure_active`

method`random_circuit`

method