Quantum Builders ClubYour first quantum circuit

Run your first quantum circuit

The club's Day 1 circuit, free on this page: about two minutes, with no account and no card.

Day 1 · Your first quantum circuitsimulated on this page

50049605041

{'0': 496, '1': 504}

The same circuit in Qiskit

qc = QuantumCircuit(1, 1)
qc.h(0)            # superposition
qc.measure(0, 0)   # read the qubit
print(qc.draw())

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

plot_histogram(counts)
Simulated on this page in a few lines of JavaScript, not Qiskit: it works out the 50/50 exactly, then picks each of the 1,000 shots with your browser's random numbers. Qiskit's simulator gives results like these. Members run the Qiskit code itself, and send it to a real IBM quantum computer from Day 30.

One more circuit

Now entangle two qubits

Add a second qubit and one CNOT gate, and the two qubits' answers stop being independent.

Day 2 · Entangle two qubitssimulated on this page

5005030000101049711

{'00': 503, '11': 497}

The same circuit in Qiskit

qc = QuantumCircuit(2, 2)
qc.h(0)          # superposition
qc.cx(0, 1)      # entangle them
qc.measure([0, 1], [0, 1])
print(qc.draw())

sim = AerSimulator()
counts = sim.run(
    transpile(qc, sim), shots=1000
).result().get_counts()
print("Entangled pair:", counts)
Simulated here in JavaScript, the same way as the first circuit. Qiskit's own counts leave out what never happened; the chart keeps 01 and 10 so you can see them stay empty.

What just happened

Your first circuit, line by line

What each line does

  • QuantumCircuit(1, 1): a circuit with 1 qubit (it starts as 0) and 1 classical bit, a little box to write the answer in.
  • qc.h(0): the Hadamard gate. It puts the qubit into superposition: a mix of 0 and 1 that only picks one when you measure it. Picture a coin spinning on a table. Unlike the coin, there's no hidden answer waiting inside: the measurement makes it. In the maths, H gives 0 and 1 equal amplitudes of 1/√2 each.
  • qc.measure(0, 0): look at qubit 0 and write the result into bit 0. You get 0 or 1, each with probability (1/√2)² = 1/2. That's the amplitude squared.
  • print(qc.draw()): draws your circuit in text: the H box, then the meter M.
  • AerSimulator(): Qiskit Aer, a simulator that runs quantum circuits on an ordinary computer.
  • transpile(qc, sim): translates your circuit into the gates this particular machine understands. The simulator barely needs it; real quantum hardware does, so builders always transpile.
  • shots=1000: run the circuit 1,000 times, with a fresh qubit each time. One shot is one coin flip.
  • .result().get_counts(): the tally. How many 0s, how many 1s.
  • plot_histogram(...): turns the tally into your chart.

Why not exactly 500/500?

Every shot is a separate measurement with a 50% chance each way, so the totals wobble. That's sampling noise, and it's exactly what should happen:

  • With 1,000 shots, about 95 runs in 100 land between 469 and 531.
  • Exactly 500/500 turns up only about once in every 40 runs.
  • Run the cell again: new numbers. Not a bug.

And here's why it's a feature. Quantum computers hand you answers as statistics, so builders need to know how big the wobble is. Measured as a share of all your shots, it shrinks as you add more: four times the shots halves it. That's how you decide how many shots a job needs, and how you tell a real effect from noise. On Day 8, your own test suite uses exactly this idea to catch a rigged coin.

One honest note

This simulator is classical software. It works out the 50/50 exactly, then picks each outcome with a pseudo-random number generator. On a real quantum computer, the randomness is physical. On Day 30, your real quantum hardware course unlocks.

On a laptop?

Run the real Qiskit code in Colab, Google's free notebook in your browser. It needs a Google account, and its first cell takes about a minute to install Qiskit.

Next: your first quantum repo, live by Day 5

Stop watching quantum. Start shipping it.

Start my 7-day free trial

$0 today. 7 days free, then $7.99 a week or $190 a year. Cancel any time.

Detail C · A qubit's state