Skip to content
Kartikey Purohit
← Course overview

Sample Papers

Paper 3

Fundamentals of Quantum Computing Using Qiskit v2.X Developer Flavor: transpilation, execution modes, and error mitigation.

Questions 34 (half-length paper; real exam is 68)
Time limit 45 minutes (~79 seconds/question)
Passing target 24 / 34 ≈ 69% (mirrors the real 47/68 threshold)
Answer format Single best answer A–D unless a question says "Choose TWO"

Instructions

  1. Assume qiskit 2.x, qiskit-ibm-runtime (V2 primitives), and qiskit-aer are installed; all imports shown are the only ones needed.
  2. Qiskit's little-endian convention applies everywhere: qubit 0 is the rightmost character in bitstrings, Pauli strings, and statevector labels.
  3. Numerical outputs are exact up to floating-point rounding; pick the closest option.
  4. No notes, no interpreter. Time yourself. Answers are in paper-03-answers.md.

Section 1 — Create Quantum Circuits (Q1–Q6)

Q1. What does this code print?

from qiskit import QuantumCircuit
from qiskit.transpiler import generate_preset_pass_manager
 
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
pm = generate_preset_pass_manager(optimization_level=1,
                                  basis_gates=['rz', 'sx', 'x', 'cx'])
isa = pm.run(qc)
print(sorted(isa.count_ops().keys()))
  • A. ['cx', 'h']
  • B. ['cx', 'rz', 'sx']
  • C. ['rz', 'sx']
  • D. ['cx', 'u']

Q2. What does this code print?

from qiskit import QuantumCircuit
 
qc = QuantumCircuit(3)
qc.h([0, 1, 2])
qc.cx(0, 1)
qc.cx(1, 2)
qc.cz(0, 2)
print(qc.depth())
  • A. 3
  • B. 4
  • C. 5
  • D. 6

Q3. What does this code print?

from qiskit import QuantumCircuit
from qiskit.transpiler import generate_preset_pass_manager, CouplingMap
 
qc = QuantumCircuit(3)
qc.h(0)
qc.cx(0, 1)
qc.cx(0, 2)
pm = generate_preset_pass_manager(optimization_level=0,
                                  basis_gates=['rz', 'sx', 'x', 'cx'],
                                  coupling_map=CouplingMap([[0, 1], [1, 2]]))
isa = pm.run(qc)
print(isa.count_ops().get('h', 0))
  • A. 0
  • B. 1
  • C. 3
  • D. It raises an error — level 0 cannot route circuits

Q4. Which sequence lists the stages of a preset staged pass manager in the order they run?

  • A. layout → init → translation → routing → optimization → scheduling
  • B. init → layout → routing → translation → optimization → scheduling
  • C. init → translation → layout → routing → scheduling → optimization
  • D. layout → routing → optimization → translation → scheduling → init

Q5. What does this code print?

from qiskit import QuantumCircuit
 
a = QuantumCircuit(2)
a.h(0)
a.cx(0, 1)
b = a.inverse()
c = a.compose(b)
print(c.size(), c.depth())
  • A. 4 4
  • B. 0 0
  • C. 4 2
  • D. 2 2

Q6. Which statement about generate_preset_pass_manager optimization levels is TRUE?

  • A. Level 0 skips layout and routing entirely, so the output may violate the coupling map
  • B. Level 3 applies the most aggressive optimization and typically yields the lowest gate counts
  • C. After pm.run(qc) you must still call transpile() to obtain an ISA circuit
  • D. Choosing level 1 or higher removes the requirement to pass ISA circuits to hardware primitives

Section 2 — Perform Quantum Operations (Q7–Q12)

Q7. Which measurement-probability dictionary does this code print?

from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
 
qc = QuantumCircuit(2)
qc.x(1)
sv = Statevector.from_instruction(qc)
print(sv.probabilities_dict())
  • A. {'01': 1.0}
  • B. {'10': 1.0}
  • C. {'11': 1.0}
  • D. {'00': 1.0}

Q8. What does this code print?

from qiskit.quantum_info import Statevector, SparsePauliOp
 
sv = Statevector.from_label('01')
op = SparsePauliOp(['ZZ'])
print(sv.expectation_value(op).real)
  • A. 1.0
  • B. -1.0
  • C. 0.0
  • D. It raises an error — expectation_value needs a Pauli, not a SparsePauliOp

Q9. Which probability dictionary does this code print (up to float rounding)?

from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
 
qc = QuantumCircuit(1)
qc.h(0)
qc.x(0)
qc.h(0)
print(Statevector.from_instruction(qc).probabilities_dict())
  • A. {'0': 1.0}
  • B. {'1': 1.0}
  • C. {'0': 0.5, '1': 0.5}
  • D. The result is random, so it cannot be predicted

Q10. What does this code print?

from qiskit import QuantumCircuit
from qiskit.quantum_info import Operator
 
a = QuantumCircuit(2)
a.swap(0, 1)
 
b = QuantumCircuit(2)
b.cx(0, 1)
b.cx(1, 0)
b.cx(0, 1)
 
print(Operator(a).equiv(Operator(b)))
  • A. True
  • B. False
  • C. It raises an error — the circuits have different gate sets
  • D. True, but only if both circuits are transpiled first

Q11. Which snippet builds the observable H = 2·XX − 3·ZZ for use with the Estimator?

  • A. SparsePauliOp.from_list([("XX", 2.0), ("ZZ", -3.0)])
  • B. SparsePauliOp.from_list([(2.0, "XX"), (-3.0, "ZZ")])
  • C. Pauli("2XX - 3ZZ")
  • D. SparsePauliOp("XX") * 2 - "ZZ" * 3

Q12. A qubit is in the state |+⟩. After applying the S gate, where does its Bloch vector point?

  • A. −X (the state |−⟩)
  • B. +Y (the state |+i⟩)
  • C. −Y (the state |−i⟩)
  • D. −Z (the state |1⟩)

Section 3 — Run Quantum Circuits (Q13–Q17)

Q13. A researcher must run 500 independent randomized-benchmarking circuits. No circuit depends on the result of another, and she wants the scheduler to parallelize the jobs efficiently without paying for exclusive backend access. Which execution mode fits best?

  • A. Job mode, submitting each circuit as a separate job
  • B. Session mode
  • C. Batch mode
  • D. Local mode on StatevectorSampler

Q14. Which snippet correctly creates an Estimator inside a session?

  • A.
    with Session(backend=backend) as session:
        estimator = EstimatorV2(mode=session)
  • B.
    estimator = EstimatorV2(mode="session")
  • C.
    session = Session()
    estimator = EstimatorV2(backend=backend)
  • D.
    with Session(backend=backend):
        estimator = EstimatorV2()

Q15. You submit a circuit that was never transpiled (it still contains h gates and violates the coupling map) to SamplerV2 running on real IBM hardware. What happens?

  • A. The service transpiles it automatically before execution
  • B. The job is rejected with an error — V2 primitives require ISA circuits
  • C. It runs, but with reduced fidelity
  • D. The unsupported gates are silently dropped

Q16. Which statement correctly describes job mode?

  • A. Each primitive.run() call is an independent job that queues on its own, with no dedicated backend window
  • B. It reserves the backend exclusively until the job finishes
  • C. It keeps classical state between successive jobs
  • D. It can only be used with simulators

Q17. What does this code print?

from qiskit import QuantumCircuit
from qiskit.primitives import StatevectorSampler
 
qc = QuantumCircuit(1, 1)
qc.x(0)
qc.measure(0, 0)
result = StatevectorSampler().run([qc], shots=100).result()
print(result[0].data.c.get_counts())
  • A. {'1': 100}
  • B. {'0': 100}
  • C. {'1': 1.0}
  • D. It raises an error — local samplers do not accept shots

Section 4 — Use the Sampler Primitive (Q18–Q21)

Q18. What does this code print?

from qiskit import QuantumCircuit
from qiskit.primitives import StatevectorSampler
 
qc = QuantumCircuit(2)
qc.x(0)
qc.measure_all()
res = StatevectorSampler().run([qc], shots=200).result()
print(res[0].data.meas.get_counts())
  • A. {'01': 200}
  • B. {'10': 200}
  • C. It raises an AttributeError — the register is named c, not meas
  • D. {'1': 200}

Q19. You pass a circuit with no measurement instructions to SamplerV2. What happens?

  • A. It returns the exact statevector instead of counts
  • B. It returns an empty counts dictionary
  • C. It raises an error — Sampler circuits must contain measurements
  • D. It automatically appends measure_all() and runs

Q20. Which snippet enables dynamical decoupling with the XpXm sequence on a Sampler?

  • A.
    sampler.options.dynamical_decoupling.enable = True
    sampler.options.dynamical_decoupling.sequence_type = "XpXm"
  • B. sampler.options.resilience_level = 1
  • C. sampler.options.dd = "XpXm"
  • D. sampler.options.twirling.enable_gates = True

Q21. Which option is NOT available on SamplerV2?

  • A. options.default_shots
  • B. options.dynamical_decoupling
  • C. options.twirling
  • D. options.resilience_level

Section 5 — Use the Estimator Primitive (Q22–Q25)

Q22. What does this code print?

from qiskit import QuantumCircuit
from qiskit.primitives import StatevectorEstimator
from qiskit.quantum_info import SparsePauliOp
 
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
obs = [SparsePauliOp('ZZ'), SparsePauliOp('XX'), SparsePauliOp('XZ')]
res = StatevectorEstimator().run([(qc, obs)]).result()
print(res[0].data.evs.round(4))
  • A. [1. 1. 0.]
  • B. [1. -1. 0.]
  • C. [0. 0. 0.]
  • D. [1. 1. 1.]

Q23. You transpiled qc to isa = pm.run(qc) for a 127-qubit backend. Before calling estimator.run([(isa, obs)]), what must you do to the observable obs?

  • A. obs = obs.apply_layout(isa.layout)
  • B. obs = obs.apply_layout(qc.layout)
  • C. isa.apply_layout(obs)
  • D. Nothing — observables are mapped automatically by the service

Q24. Moving estimator.options.resilience_level from 1 to 2 adds which technique?

  • A. Probabilistic error cancellation (PEC)
  • B. Zero-noise extrapolation (ZNE)
  • C. Dynamical decoupling
  • D. Measurement (readout) error mitigation

Q25. (Choose TWO) Which of the following are post-processing error mitigation techniques, as opposed to error suppression applied before/during execution?

  • A. Zero-noise extrapolation (ZNE)
  • B. Dynamical decoupling
  • C. Probabilistic error cancellation (PEC)
  • D. Pauli twirling

Section 6 — Visualize Circuits, Measurements, and States (Q26–Q29)

Q26. Which diagram does qc.draw('text') produce for this circuit?

from qiskit import QuantumCircuit
 
qc = QuantumCircuit(2)
qc.h(1)
qc.cx(1, 0)
  • A.
         ┌───┐
    q_0: ┤ H ├──■──
         └───┘┌─┴─┐
    q_1: ─────┤ X ├
              └───┘
  • B.
              ┌───┐
    q_0: ─────┤ X ├
         ┌───┐└─┬─┘
    q_1: ┤ H ├──■──
         └───┘
  • C.
    q_0: ───────■──
         ┌───┐┌─┴─┐
    q_1: ┤ H ├┤ X ├
         └───┘└───┘
  • D.
         ┌───┐┌───┐
    q_0: ┤ H ├┤ X ├
         └───┘└─┬─┘
    q_1: ───────■──

Q27. You call plot_bloch_multivector on the Bell state (|00⟩ + |11⟩)/√2. What do the two Bloch spheres show?

  • A. Both vectors pointing to +X
  • B. One vector at +Z, the other at −Z
  • C. Both vectors with zero length (at the center of each sphere)
  • D. Both vectors at +Z

Q28. You have counts_sim (ideal simulator) and counts_hw (hardware) and want them side by side in ONE histogram with a legend. Which call is correct?

  • A. plot_histogram([counts_sim, counts_hw], legend=["sim", "hw"])
  • B. plot_histogram(counts_sim + counts_hw)
  • C. plot_histogram({**counts_sim, **counts_hw})
  • D. plot_histogram(counts_sim, counts_hw)

Q29. On a qsphere produced by plot_state_qsphere, what does the color of each blob encode?

  • A. The measurement probability of that basis state
  • B. The relative phase of that basis-state amplitude
  • C. The qubit index
  • D. The degree of entanglement

Section 7 — Retrieve and Analyze Results (Q30–Q32)

Q30. What does this code print?

counts = {'0': 600, '1': 400}
shots = 1000
expval_z = (counts['0'] - counts['1']) / shots
print(expval_z)
  • A. 0.2
  • B. -0.2
  • C. 0.6
  • D. 0.36

Q31. A job finished overnight and your Python session is gone. You have the job ID string. How do you retrieve the job?

  • A. job = service.job("d8a8...")
  • B. job = SamplerV2.load("d8a8...")
  • C. job = Session.retrieve("d8a8...")
  • D. job = service.jobs("d8a8...")[0]

Q32. An Estimator result has a standard error of 0.04 at 1,000 shots. Approximately how many shots do you need to reduce the standard error to 0.02?

  • A. 2,000
  • B. 4,000
  • C. 8,000
  • D. 1,000,000

Section 8 — Operate with OpenQASM (Q33–Q34)

Q33. What does this code print?

import qiskit.qasm3
 
program = """
OPENQASM 3.0;
include "stdgates.inc";
qubit[2] q;
bit[2] c;
h q[0];
cx q[0], q[1];
c = measure q;
"""
qc = qiskit.qasm3.loads(program)
print(qc.num_qubits, qc.count_ops()['measure'])
  • A. 2 2
  • B. 2 1
  • C. It raises an error — c = measure q; is not valid OpenQASM 3
  • D. 4 2

Q34. Which feature exists in OpenQASM 3 but NOT in OpenQASM 2?

  • A. The include statement
  • B. Classical control flow such as if/while blocks and typed classical variables
  • C. Defining quantum registers
  • D. The cx two-qubit gate

End of Paper 03. Check your work in paper-03-answers.md.