"This lab turns protocol language into concrete manipulation. The main question is not whether the circuit executes. The main question is whether you can change preparation, basis, or reporting one at a time and still keep the explanation stable.\n"
"Use the same lab cycle as before: predict, edit one thing, render, inspect, and revise. The only difference here is that you should now classify the edit even more explicitly. Did you change the prepared state, the measurement basis, or the classical reporting layer? If you cannot answer that, the edit was not conceptually controlled enough.\n"
"Start with a one-qubit circuit. Move `X`, `H`, and `Z` around and explain why the final counts change or fail to change. The purpose is to stop treating gate names as slogans and start treating them as transformations in sequence.\n"
"editable_code = '\\ncircuit = QuantumCircuit(1, 1)\\n# [1] Try changing the preparation gate sequence.\\ncircuit.x(0)\\ncircuit.h(0)\\n# [2] Optionally add Z or another H before measurement.\\n# circuit.z(0)\\n# circuit.h(0)\\n# [3] Measure the result.\\ncircuit.measure(0, 0)\\n'\n",
"The first lab makes a simple but essential point: the meaning of a gate sequence is not the sum of independent gate slogans. Order matters. Context matters. A `Z` in the middle of a sequence can be invisible in one immediate view and decisive in a later one.\n"
"quiz_block([{'prompt': 'What is the best reason to compare counts across different shot budgets?', 'options': ['To separate stable probability claims from normal sampling fluctuation', 'To reduce circuit depth', 'To change the prepared state'], 'correct_index': 0, 'explanation': 'Shot scaling teaches you how much statistical noise to expect from the same circuit.'}, {'prompt': 'What does swapping classical bit targets test?', 'options': ['Whether your explanation tracks the reporting layer instead of only the quantum layer', 'Whether CNOT still works', 'Whether the backend supports measurement'], 'correct_index': 0, 'explanation': 'Good reasoning follows the evidence all the way into the bitstring labels.'}], heading='Measurement Lab Checkpoint A')\n"
"## Lab 2: Basis Rotation On A Two-Qubit Circuit\n",
"\n",
"Return to the Bell-style preparation and vary the final Hadamard placement. Ask the stronger question every time: what did this edit change in the protocol, and what evidence would support that claim?\n"
"step_reference_table([{'marker': '[1]', 'code_focus': 'Prepare a Bell-style correlated state with `H` and `CX`.', 'diagram_effect': 'The first two operations create a structured two-wire object rather than two independent qubits.', 'why_it_matters': 'Measurement interpretation depends on what was prepared before the final question is asked.'}, {'marker': '[2]', 'code_focus': 'Rotate one qubit with `H` immediately before measurement.', 'diagram_effect': 'The final question changes on that wire without erasing the rest of the preparation story.', 'why_it_matters': 'Basis changes are part of the experiment design, not cosmetic extras.'}, {'marker': '[3]', 'code_focus': 'Measure into explicitly chosen classical bits.', 'diagram_effect': 'The circuit commits to a specific readout question and a specific reporting layout.', 'why_it_matters': 'Classical wiring is part of the evidence trail and can itself become a source of confusion.'}])\n"
"editable_code = '\\ncircuit = QuantumCircuit(2, 2)\\n# [1] Prepare the correlated state.\\ncircuit.h(0)\\ncircuit.cx(0, 1)\\n# [2] Change the basis of the first measurement question.\\ncircuit.h(0)\\n# [3] Measure both qubits into the matching classical bits.\\ncircuit.measure([0, 1], [0, 1])\\n'\n",
"The last lab isolates classical wiring. Swapping the target classical bits should not be explained as a change in quantum preparation. It is a reporting change. That sounds obvious when written plainly, but many learners still misread the resulting bitstrings unless the notebook forces the distinction.\n"
" instructions='Switch between direct and swapped classical mappings and explain how the evidence labels change even if the quantum preparation story does not.',\n",
"This exercise is professionally important because many debugging mistakes come from the reporting layer, not from the state preparation layer. A world-class lecture series should train that suspicion early rather than treating it as an advanced nuisance.\n"
"These three labs together teach a simple review pattern. First ask whether the preparation changed. If not, ask whether the measurement basis changed. If not, ask whether only the reporting layer changed. That sequence is powerful because it narrows explanation quickly. It also stops you from inventing dramatic quantum stories for what may only be a bookkeeping issue.\n",
"\n",
"The debrief is worth reading carefully because many learners still default to a single undifferentiated sentence such as \u201cthe circuit output changed.\u201d That sentence contains almost no engineering value. A stronger sentence might be: \u201cThe prepared Bell-style state stayed the same, but the added Hadamard changed the first qubit's measurement basis, so the empirical correlation pattern now answers a different question.\u201d That is the level of explanation this lab is trying to normalize.\n"
"quiz_block([{'prompt': 'If a final Hadamard changes the counts drastically, what is the first serious question to ask?', 'options': ['Did I change the measurement basis rather than merely add decoration?', 'Did the notebook theme corrupt the circuit?', 'Did the number of qubits change automatically?'], 'correct_index': 0, 'explanation': 'The basis question is the right first interpretation, not panic.'}, {'prompt': 'Why keep counts and probabilities conceptually separate in the same notebook?', 'options': ['Because one is sampled evidence and the other is an idealized expectation derived from the model', 'Because they should never be compared', 'Because counts are only for advanced users'], 'correct_index': 0, 'explanation': 'Serious measurement reasoning compares the ideal story with sampled evidence carefully.'}], heading='Measurement Lab Checkpoint B')\n"