This task sheet accompanies the notebook Qiskit_qubit_measure.ipynb.
In this lab, we explored how to prepare and measure the basis states of a qubit:
- |0⟩ (default starting state)
- |1⟩ (using an X gate to flip the qubit)
We used the AerSimulator in Qiskit to run the experiments.
- Run the given program for |0⟩ and |1⟩.
- Record the counts for 512 shots.
- Question: Are the results deterministic or random? Why?
- Modify the code to run with 10 shots and 1000 shots.
- Observe the results. Do they change? Why or why not?
- Modify the circuit to apply a Hadamard (H) gate before measurement:
qc = QuantumCircuit(1, 1) qc.h(0) qc.measure_all()
- Run with 512 shots.
- Question: What outcomes do you see? Are they deterministic or probabilistic?
- Create a circuit that applies X followed by H:
qc.x(0) qc.h(0) qc.measure_all()
- Run with 512 shots.
- Predict the results before running: what distribution do you expect?
(Hint: Think about how H acts on |1⟩).
- Build a 2-qubit circuit where:
- Qubit 0 is |0⟩
- Qubit 1 is |1⟩
- Measure both.
- Run with 512 shots.
- Question: What outputs do you expect? Does the simulator confirm it?
- Remember:
- Qubits start in |0⟩.
Xflips |0⟩ ↔ |1⟩.Hcreates superposition.- Measurement collapses the qubit into
0or1.