Put a qubit in superposition
The Hadamard gate, and why 1,000 shots almost never split exactly 500/500.

A qubit in superposition holds no single value. It carries a weight on each answer, a number that sets how likely that answer is, and its answer is not fixed until it is measured.
The Hadamard gate, h in Qiskit, puts a fresh qubit into that state in one line. The circuit below runs it for 1,000 shots and prints the tally.
What a superposed qubit holds
An ordinary bit holds a 0 or a 1 whether or not you have looked at it; looking only tells you which one it already was.
A qubit after a Hadamard gate holds no value to find before the measurement. It carries a weight on each outcome, equal here, so each answer is equally likely. A qubit with weights on both answers at once is in a superposition.
The measurement turns those weights into one answer, and running the circuit again can give the other answer. To estimate how likely each answer is, a quantum program runs the circuit many times and returns the tally.
A weight has a size, which sets how likely its answer is: the share of shots that read an answer is its weight's size squared, so two equal weights of about 0.7 give shares of one half each. Lesson 4 checks this rule against measured tallies.
A weight also has a sign, which never shows in a tally on its own. The sign shows when another gate acts on the weights before the measurement, because gates transform the weights, sign included; in this lesson, a sign first changes a tally in the two-Hadamard assignment.
The Hadamard gate
Takes a qubit at 0 and leaves it weighted evenly between 0 and 1; takes a qubit at 1 and does the same with the sign of one weight flipped. Measure either and each answer is equally likely. It is its own inverse: applied twice in a row, it returns the qubit to where it started.
The circuit, then the code
# 'backend' already exists when this runs: it is whatever you pick in the Run on Qollab dialog.
from qiskit import QuantumCircuit
from qiskit.providers.jobstatus import JobStatus
import time
shots = 1000
qc = QuantumCircuit(1, 1)
1qc.h(0)
qc.measure(0, 0)
print(qc)
2job = backend.run(qc, shots=shots)
while job.status() not in (JobStatus.DONE, JobStatus.ERROR, JobStatus.CANCELLED):
time.sleep(5)
counts = job.result().get_counts()
print(counts)
for bits, n in sorted(counts.items()):
3 print(f"{bits}: {n:4d} {100 * n / shots:5.1f}% {'█' * (50 * n // shots)}")
- 1the Hadamard gate: half 0, half 1, and no value at all until it is measured
- 2one job per press of Run: press it again for another tally
- 3the share next to each bar, from lesson 1's second assignment
Two things changed in what the code does since lesson 1. The gate is h instead of x, and the bar loop prints each bar's share next to it, which was lesson 1's second assignment. The qubit, the bit, the measurement, the job and backend do the same as before.
Run the circuit, three presses
A shot is one execution of the circuit, start to finish. A job is one press: you press Run on Qollab, choose a simulator in the dialog, then press the dialog's Run. This listing's job holds 1,000 shots. The Playground files one job per press, so a second tally needs a second press.
Predict the tally. Then open the project, press Run on Qollab, choose IonQ Aria 1 under Remotely Run Simulators, and press Run. When the tally is in, note it and press twice more, choosing Aria 1 each time. Our first press took 17.9 seconds.

Our three presses on 15 September 2026, on the Aria 1 noise model, came back {'0': 487, '1': 513}, then {'0': 505, '1': 495}, then {'0': 511, '1': 489}. One circuit gave three different splits, none of them 500/500.
The ideal is exactly one half each, and a finite sample rarely lands on it. Even a perfect simulator gives 500 of 1,000 only about one press in forty.
Fork the project now, the way lesson 1 showed, so the edits below land in your own copy. The three assignments build on each other in order.
Assignment: one shot at a time
- In your fork, set
shots = 1. - Press three times, and write down each tally as it comes in.
- Each dict can only be
{'0': 1}or{'1': 1}. Try to reconstruct the 50/50 split from your three dicts. - Write one sentence: what does one shot tell you about the weights inside the qubit?
Solution
One shot tells you which answer came out this time. A single {'1': 1} is consistent with odds of 50/50 and with 99/1, so it cannot tell them apart; only the shares across many shots estimate the weights' sizes.
Why the split is hardly ever exactly half
Over 1,000 shots of a fair split, the count of 1s scatters from press to press around its expected value, 500. The typical distance from 500, the standard deviation, is the square root of 1,000 × ½ × ½, which is about 16 shots. Nineteen presses in twenty land within twice that, between about 468 and 532.
The same arithmetic at other sizes gives the rule for choosing a shot count. At 100 shots the scatter is 5 shots, which is 5% of the sample. At 10,000 it is 50 shots, which is half a percent.
Multiplying the shots by a hundred divides the scatter, as a share, by ten: precision grows with the square root of the shot count.
The weights inside the qubit are the same on every press; only the sample changes. Sampling also explains lesson 1's two presses, where one caught a stray noise shot and the other did not.
Assignment: make the split move
- Set
shots = 100. Before you run, write down the band you expect the count of1s to land in: the expected count, 50, plus or minus twice the scatter, where the scatter is half the square root of the shot count: for 100 shots, half of 10, which is 5. That gives 40 to 60. - Press Run on Qollab and choose IonQ Aria 1.
- Note whether the count landed inside the band. Read the dict for the count and the Probabilities panel for the share.
- Set
shots = 10000and work out its band the same way. The simulator is free at 10,000 shots too. - Press Run on Qollab and choose IonQ Aria 1.
- Note whether the count landed inside its band.
One press cannot prove the rule: a press can only land inside or outside the band the rule predicts.
Solution
At 10,000 shots the scatter is 50, so the band is 4,900 to 5,100: within a percentage point of half. At 100 shots the band is 40 to 60: within ten points. Either press can miss its band about once in twenty, so one miss does not break the rule.
A test for a hidden value
A tally alone cannot tell a superposition from a coin: one shot gives one answer, with no way to predict it. Suppose the qubit after one Hadamard held a 0 or a 1 all along, and the measurement only revealed it.
The Hadamard spreads a qubit at 0 evenly, and it spreads a qubit at 1 evenly too. So if the qubit really held a hidden value, a second Hadamard would spread that value out again. The tally after two Hadamards would be half and half, just like after one.
The Hadamard is its own inverse because of the signs. After one Hadamard the two weights are equal in size and share a sign. The second Hadamard sends the weight on 0 to both answers with the same sign, and the weight on 1 to both answers with the sign of its 1 half flipped. On 1 the two halves cancel; on 0 they add. So everything collects on 0, which a hidden value cannot produce.
Assignment: two Hadamards in a row
- Set
shotsback to1000. - Add a second
qc.h(0)directly under the first, before the measurement. - Write down two predictions: half and half, from the hidden-value argument above, and the gate row's answer, its own inverse.
- Decide which you believe, then run.
Solution
Every shot reads 0, apart from a few stray 1s from the noise model. The hidden-value argument predicted half and half and was wrong.
qc = QuantumCircuit(1, 1)
qc.h(0)
qc.h(0)
qc.measure(0, 0)
The weight on 1 reached the measurement as two halves with opposite signs, and they cancelled. A qubit that started at 1 would give the same even tally after one Hadamard, with its two weights' signs opposite, and the second Hadamard would send everything to 1 instead. Lesson 5 uses this add-and-cancel step for its search.
Lesson 3 adds a second qubit and the CNOT, a gate that acts on two qubits at once.
Stay in the loop.
Get the latest tutorials, demos, and project showcases straight to your inbox. No noise, just the good stuff.
Enable JavaScript to sign up.
Qollab updates only. Unsubscribe any time. Privacy Policy.
On this page
