Day 5 — Sampler & Results
Question Bank
20 questions. Answers and explanations in solution-bank.md. No peeking.
Q1. What does the SamplerV2 primitive return for each PUB?
- A. Expectation values of observables supplied in the PUB
- B. Per-shot measurement samples / bitstring counts from the circuit's classical registers
- C. Quasi-probability distributions after readout mitigation
- D. The final statevector of the circuit
Q2. Given:
from qiskit import QuantumCircuit
from qiskit.primitives import StatevectorSampler
qc = QuantumCircuit(2)
qc.h(0); qc.cx(0, 1)
qc.measure_all()
result = StatevectorSampler().run([qc], shots=1024).result()
counts = result[0].data.c.get_counts()What happens on the last line?
- A.
countsis a dict like{'00': 5xx, '11': 5xx} - B.
AttributeError— the register is namedmeas, notc - C.
KeyError: 'c' - D. An empty dict, because
measure_allstores data underresult.data.counts
Q3. Which is a valid SamplerV2 PUB that also fixes the shot count for that PUB?
- A.
(circuit, shots) - B.
(circuit, observable, shots) - C.
(circuit, parameter_values, shots) - D.
(shots, circuit, parameter_values)
Q4. Given:
job = sampler.run([(qc, None, 333)], shots=1000)How many shots are executed for this PUB?
- A. 1000 — the
run()argument always wins - B. 333 — per-PUB shots override the
run()-level value - C. 1333 — they are added
- D. It raises an error because shots are specified twice
Q5. Given:
result = sampler.run([qc_a, qc_b, qc_c]).result()How do you get the counts of qc_b (all three use measure_all())?
- A.
result.get_counts(qc_b) - B.
result[1].data.meas.get_counts() - C.
result.data[1].meas.get_counts() - D.
result[2].data.meas.get_counts()
Q6. A 3-qubit circuit built with measure_all() is run with shots=512. For
ba = result[0].data.meas, what are ba.num_shots and ba.num_bits?
- A.
num_shots=512,num_bits=3 - B.
num_shots=3,num_bits=512 - C.
num_shots=512,num_bits=8 - D.
num_shots=1536,num_bits=1
Q7. What does result[0].data.meas.get_bitstrings() return?
- A. A dict mapping bitstrings to counts
- B. A list of unique bitstrings observed
- C. A list with one bitstring per shot (length =
num_shots) - D. A NumPy array of integers
Q8. Given:
q = QuantumRegister(2, 'q')
a = ClassicalRegister(1, 'a') # added first
b = ClassicalRegister(1, 'b') # added second
qc = QuantumCircuit(q, a, b)
qc.x(0)
qc.measure(0, a[0]) # always 1
qc.measure(1, b[0]) # always 0
res = StatevectorSampler().run([qc], shots=10).result()[0]
print(res.join_data().get_counts())What is printed?
- A.
{'10': 10} - B.
{'01': 10} - C.
{'1': 10, '0': 10} - D.
TypeError— join_data requires register names
Q9. Which line raises an error for a qiskit_ibm_runtime SamplerV2 instance?
- A.
sampler.options.default_shots = 2048 - B.
sampler.options.dynamical_decoupling.enable = True - C.
sampler.options.twirling.enable_measure = True - D.
sampler.options.resilience_level = 1
Q10. Which is a valid value for sampler.options.dynamical_decoupling.sequence_type?
- A.
"XZXZ" - B.
"XpXm" - C.
"ZZ" - D.
"YY4"
Q11. Which set contains only real fields of sampler.options.twirling?
- A.
enable_gates,enable_measure,num_randomizations,shots_per_randomization - B.
enable_gates,enable_measure,zne_factors,shots_per_randomization - C.
enable_twirling,randomization_count,measure_twirl - D.
enable_gates,resilience_level,num_randomizations
Q12. A colleague passes a circuit with no measurements to SamplerV2. Per the exam's framing, which statement is correct?
- A. Sampler measures all qubits automatically in the Z basis
- B. Sampler circuits must contain measurements — without them there is no data to sample
- C. Sampler infers the measurement from the observable in the PUB
- D. The job fails only on real hardware, but simulators add measurements
Q13. Given:
qc = QuantumCircuit(2, 2)
qc.h(0); qc.cx(0, 1)
qc.measure([0, 1], [0, 1])
result = sampler.run([qc]).result()Which expression retrieves the counts?
- A.
result[0].data.meas.get_counts() - B.
result[0].data.c.get_counts() - C.
result[0].get_counts() - D.
result[0].data.get_counts('c')
Q14. Your kernel restarted after submitting a job yesterday. You saved the job ID string. How do you reconnect to the job?
- A.
job = QiskitRuntimeService().job("d1e2f3a4b5") - B.
job = SamplerV2.retrieve("d1e2f3a4b5") - C.
job = service.jobs("d1e2f3a4b5") - D. You cannot — job handles die with the Python process
Q15. Which call correctly lists only your queued/running jobs on one backend?
- A.
service.jobs(backend_name="ibm_torino", pending=True) - B.
service.jobs(backend="ibm_torino", status="active") - C.
service.list_jobs(filter="pending", device="ibm_torino") - D.
service.job(backend_name="ibm_torino", pending=True)
Q16. Which method returns the quantum processor execution time consumed by a job (in seconds), useful for tracking your account quota?
- A.
job.metrics() - B.
job.usage() - C.
job.status() - D.
job.qpu_time
Q17. A 2-qubit Bell circuit returns counts = {'00': 412, '11': 588} over 1000 shots.
What is the estimated probability of measuring '11'?
- A. 0.412
- B. 0.5 — Bell states are always 50/50 by definition
- C. 0.588
- D. 588
Q18. Single-qubit counts: {'0': 300, '1': 700} over 1000 shots. What is the manual
estimate of ⟨Z⟩?
- A. +0.4
- B. −0.4
- C. 0.7
- D. −0.7
Q19. Your Sampler-based estimate of a probability has statistical error ε at 1000 shots. Approximately how many shots do you need to reduce the error to ε/2?
- A. 2000
- B. 4000
- C. 8000
- D. 1,000,000
Q20. Which statement about V2 result objects is TRUE?
- A.
job.result()returns aPrimitiveResult, which is iterable and yields onePubResultper PUB - B.
job.result()returns a dict keyed by circuit name - C.
result[0].metadataholds the bitstrings;result[0].dataholds shot counts only - D. Job-level metadata is accessed as
result[0].data.metadata