Converting a Bell circuit, line by line

The two-qubit circuit that creates entanglement, written in all five targets and compared.

7 min read · reviewed December 2026

The circuit

A Hadamard on qubit 0, a CNOT from qubit 0 to qubit 1, then measurement of both. It produces 00 and 11 with probability 50 percent each.

Qiskit

from qiskit import QuantumCircuit, transpile
from qiskit_aer import AerSimulator
from math import pi

qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.measure(0, 0)
qc.measure(1, 1)

sim = AerSimulator()
counts = sim.run(transpile(qc, sim), shots=1000).result().get_counts()
print(counts)

# Measurements are moved to the end of the circuit.
# Qiskit writes bit strings with qubit 0 on the RIGHT. This site writes qubit 0 on the LEFT.

Cirq

import cirq
from math import pi

q = cirq.LineQubit.range(2)
circuit = cirq.Circuit()
circuit.append(cirq.H(q[0]))
circuit.append(cirq.CNOT(q[0], q[1]))
circuit.append(cirq.measure(q[0], q[1], key="m"))

print(circuit)
result = cirq.Simulator().run(circuit, repetitions=1000)
print(result.histogram(key="m"))

# Measurements are moved to the end of the circuit.
# Cirq lists the first qubit first, like this site. The histogram keys are integers read with the first measured qubit as the most significant bit.

PennyLane

import pennylane as qml
from math import pi

dev = qml.device("default.qubit", wires=2)

@qml.qnode(dev)
def circuit():
    qml.Hadamard(wires=0)
    qml.CNOT(wires=[0, 1])
    return qml.probs(wires=[0, 1])

print(circuit())

# Measurements are moved to the end of the circuit.
# PennyLane returns exact probabilities in order of the integer value, first wire as the most significant bit, like this site.

OpenQASM 3.0

OPENQASM 3.0;
include "stdgates.inc";
qubit[2] q;
bit[2] c;
h q[0];
cx q[0], q[1];
c[0] = measure q[0];
c[1] = measure q[1];

What to notice

  • Qiskit builds a circuit object with methods and creates classical bits to receive measurements.
  • Cirq builds a list of operations on named qubits and measures into a keyed result.
  • PennyLane writes the circuit as a Python function, and returns exact probabilities and not shots.
  • OpenQASM is the same list of gates as plain text.

Try it

Questions

Why does PennyLane have no measurement lines?

It returns the probability vector of the chosen wires directly, so no sampling is involved unless you request shots.

Will Qiskit give exactly 50-50?

With 1000 shots the counts vary around 500 each. The exact chances are 50 percent.

Is the order 00 and 11 the same in every tool?

Yes for this circuit, because both bits are equal. Try an asymmetric circuit to see the order difference.

Read next

Sources and further reading

Check the original sources for exact citations.