Bengali
Languages
English
Bengali
French
German
Japanese
Korean
Portuguese
Spanish
Tamil

# qiskit.circuit.QuantumCircuit.measure¶

QuantumCircuit.measure(qubit, cbit)[source]

Measure a quantum bit (qubit) in the Z basis into a classical bit (cbit).

When a quantum state is measured, a qubit is projected in the computational (Pauli Z) basis to either $$\lvert 0 \rangle$$ or $$\lvert 1 \rangle$$. The classical bit cbit indicates the result of that projection as a 0 or a 1 respectively. This operation is non-reversible.

প্যারামিটার
রিটার্নস

রিটার্ন টাইপ

qiskit.circuit.InstructionSet

রেইজেস

CircuitError -- if arguments have bad format.

Examples

In this example, a qubit is measured and the result of that measurement is stored in the classical bit (usually expressed in diagrams as a double line):

from qiskit import QuantumCircuit
circuit = QuantumCircuit(1, 1)
circuit.h(0)
circuit.measure(0, 0)
circuit.draw()

     ┌───┐┌─┐
q: ┤ H ├┤M├
└───┘└╥┘
c: 1/══════╩═
0


It is possible to call measure with lists of qubits and cbits as a shortcut for one-to-one measurement. These two forms produce identical results:

circuit = QuantumCircuit(2, 2)
circuit.measure([0,1], [0,1])

circuit = QuantumCircuit(2, 2)
circuit.measure(0, 0)
circuit.measure(1, 1)


Instead of lists, you can use QuantumRegister and ClassicalRegister under the same logic.

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
qreg = QuantumRegister(2, "qreg")
creg = ClassicalRegister(2, "creg")
circuit = QuantumCircuit(qreg, creg)
circuit.measure(qreg, creg)


This is equivalent to:

circuit = QuantumCircuit(qreg, creg)
circuit.measure(qreg[0], creg[0])
circuit.measure(qreg[1], creg[1])