Skip to content
Kartikey Purohit
← Course overview

Sample Papers

Paper 7

Exam: Fundamentals of Quantum Computing Using Qiskit v2.X Developer Time limit: 45 minutes | Questions: 34 | Passing target: 24/34 (~69%) Difficulty flavor: HARD — every question contains at least one classic exam trap.

Instructions

  • Single best answer (A–D) unless the question explicitly says "choose TWO".
  • All code assumes Qiskit v2.x, qiskit-ibm-runtime 0.4x, and standard imports unless shown.
  • Qiskit is little-endian: qubit 0 is the rightmost character in bitstrings, Pauli strings, and statevector labels.
  • No notes, no interpreter. Mark and move on if stuck — ~79 seconds per question.

Section 1 — Create Quantum Circuits (Q1–Q6)

Q1. What does this print?

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

Q2. What does this print?

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
 
qr = QuantumRegister(2, 'q')
cr = ClassicalRegister(2, 'c')
qc = QuantumCircuit(qr, cr)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()
print(qc.num_clbits)
  • A. 2
  • B. 4
  • C. 0
  • D. It raises an error because the circuit already has a classical register

Q3. Which snippet prepares the 3-qubit GHZ state (|000⟩ + |111⟩)/√2?

  • A.
    qc.h(0); qc.h(1); qc.h(2)
  • B.
    qc.h(0); qc.cx(1, 0); qc.cx(2, 1)
  • C.
    qc.h(0); qc.cx(0, 1); qc.cx(1, 2)
  • D.
    qc.x(0); qc.cx(0, 1); qc.cx(0, 2)

Q4. After running this code, what rotation angle does the rx gate carry in bound?

import numpy as np
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
 
b = Parameter('b')
a = Parameter('a')
qc = QuantumCircuit(1)
qc.rx(b, 0)
qc.rz(a, 0)
bound = qc.assign_parameters([np.pi, 0])
  • A. 0
  • B. π
  • C. π/2
  • D. The call raises an error because parameters must be bound with a dict

Q5. This dynamic circuit is executed for 1000 shots on a simulator that supports classical feedforward. What are the counts?

from qiskit import QuantumCircuit
 
qc = QuantumCircuit(2, 2)
qc.x(0)
qc.measure(0, 0)
with qc.if_test((qc.clbits[0], 1)):
    qc.x(1)
qc.measure(1, 1)
  • A. {'01': 1000}
  • B. {'10': 1000}
  • C. Roughly {'01': 500, '11': 500}
  • D. {'11': 1000}

Q6. A single h gate is transpiled to the basis ['rz', 'sx', 'x']. Which sequence replaces it (up to global phase)?

  • A. sx · rz(π/2) · sx
  • B. rz(π/2) · sx · rz(π/2)
  • C. x · sx
  • D. rz(π) · sx · rz(π)

Section 2 — Perform Quantum Operations (Q7–Q12)

Q7. What does this print?

from qiskit.quantum_info import Pauli, Statevector
 
sv = Statevector.from_label('01')
print(sv.expectation_value(Pauli('ZI')))
  • A. -1.0
  • B. 0.0
  • C. 1.0 (up to (1+0j))
  • D. 1j

Q8. What does this print?

from qiskit.quantum_info import SparsePauliOp
 
op = SparsePauliOp.from_list([('XI', 1), ('IX', 1), ('XI', -1)])
print(op.simplify())
  • A. SparsePauliOp(['IX'], coeffs=[1.+0.j])
  • B. SparsePauliOp(['XI'], coeffs=[1.+0.j])
  • C. SparsePauliOp(['XI', 'IX', 'XI'], coeffs=[1.+0.j, 1.+0.j, -1.+0.j])
  • D. SparsePauliOp(['IX', 'XI'], coeffs=[1.+0.j, 0.+0.j])

Q9. What does this print?

from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
 
qc = QuantumCircuit(1)
qc.h(0)
qc.z(0)
qc.h(0)
sv = Statevector.from_label('0').evolve(qc)
print(sv.probabilities_dict())
  • A. {'0': 1.0}
  • B. {'1': 1.0}
  • C. {'0': 0.5, '1': 0.5}
  • D. {'0': 0.85, '1': 0.15}

Q10. Which Pauli string does this build?

from qiskit.quantum_info import SparsePauliOp
 
op = SparsePauliOp.from_sparse_list([('ZZ', [0, 2], 1.0)], num_qubits=3)
  • A. ZZI
  • B. IZZ
  • C. ZZZ
  • D. ZIZ

Q11. The identity H·X·H equals which single gate?

  • A. X
  • B. Z
  • C. Y
  • D. −X (X with an observable global sign)

Q12. What does this print?

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

Section 3 — Run Quantum Circuits (Q13–Q17)

Q13. You submit a circuit containing h and cx gates (not transpiled) directly to SamplerV2 targeting a real IBM Quantum backend. What happens?

  • A. The service transpiles it automatically before execution
  • B. It runs, but with a deprecation warning
  • C. The job is rejected with an error — V2 primitives require ISA circuits matching the backend target
  • D. It runs and silently returns incorrect results

Q14. Which snippet correctly attaches a Sampler to a session?

  • A.
    with Session(backend=backend) as session:
        sampler = SamplerV2(mode=session)
  • B.
    sampler = SamplerV2(backend=backend, session=True)
  • C.
    session = Session(backend=backend)
    sampler = session.run(SamplerV2)
  • D.
    sampler = SamplerV2()
    sampler.options.session = backend

Q15. You are running a variational algorithm where each iteration's circuits depend on the previous iteration's results, and you want to avoid re-queuing between iterations. Which execution mode fits best?

  • A. Job mode
  • B. Batch mode — the jobs are scheduled in parallel
  • C. Session mode
  • D. Local mode with StatevectorSampler

Q16. Which snippet returns the least busy real (non-simulator) operational device?

  • A. service.backends(least_busy=True)
  • B. service.get_backend('least_busy')
  • C. backend.least_busy(operational=True)
  • D. service.least_busy(operational=True, simulator=False)

Q17. How many shots are executed for the second PUB?

sampler.options.default_shots = 1024
job = sampler.run([(isa_qc1,), (isa_qc2, None, 4096)])
  • A. 1024 — default_shots overrides PUB-level values
  • B. 4096 — shots specified in a PUB take precedence for that PUB
  • C. 2560 — the two values are averaged
  • D. It raises an error — shots cannot be set per PUB

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

Q18. Which expression retrieves the counts?

from qiskit import QuantumCircuit
from qiskit.primitives import StatevectorSampler
 
qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.measure([0, 1], [0, 1])
result = StatevectorSampler().run([qc]).result()
  • A. result[0].data.meas.get_counts()
  • B. result.get_counts(0)
  • C. result[0].data.c.get_counts()
  • D. result[0].data.get_counts()

Q19. A 3-qubit circuit applies qc.x(0) then qc.measure_all() and is run with the Sampler. Which single counts key appears?

  • A. '100'
  • B. '001'
  • C. '1'
  • D. '010'

Q20. Which of the following is NOT a valid option on SamplerV2?

  • A. sampler.options.default_shots
  • B. sampler.options.dynamical_decoupling.enable
  • C. sampler.options.twirling.enable_gates
  • D. sampler.options.resilience_level

Q21. What counts key does join_data() produce?

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.primitives import StatevectorSampler
 
qr = QuantumRegister(2, 'q')
alpha = ClassicalRegister(1, 'alpha')
beta = ClassicalRegister(1, 'beta')
qc = QuantumCircuit(qr, alpha, beta)
qc.x(0)
qc.measure(0, alpha[0])
qc.measure(1, beta[0])
result = StatevectorSampler().run([qc], shots=100).result()
print(result[0].join_data().get_counts())
  • A. {'10': 100}
  • B. {'0 1': 100}
  • C. It raises an error — join_data requires a single classical register
  • D. {'01': 100}

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

Q22. isa_qc = pm.run(qc) was produced by a preset pass manager for a 127-qubit backend, and obs is a SparsePauliOp defined on the original circuit's qubits. Which PUB is correct?

  • A. (isa_qc, obs.apply_layout(isa_qc.layout))
  • B. (isa_qc, obs) — the Estimator maps the observable automatically
  • C. (qc, obs.apply_layout(qc.layout))
  • D. (isa_qc, isa_qc.apply_layout(obs))

Q23. What does this print?

from qiskit import QuantumCircuit
from qiskit.quantum_info import SparsePauliOp
from qiskit.primitives import StatevectorEstimator
 
qc = QuantumCircuit(2)
qc.h(0)
obs = [SparsePauliOp('IZ'), SparsePauliOp('ZI')]
result = StatevectorEstimator().run([(qc, obs)]).result()
print(result[0].data.evs)
  • A. [1. 0.]
  • B. [0. 0.]
  • C. [1. 1.]
  • D. [0. 1.]

Q24. Which Estimator resilience_level is the lowest one that enables zero-noise extrapolation (ZNE) by default?

  • A. 0
  • B. 1
  • C. 2
  • D. 3

Q25. What does this print?

import numpy as np
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
from qiskit.quantum_info import SparsePauliOp
from qiskit.primitives import StatevectorEstimator
 
theta = Parameter('t')
qc = QuantumCircuit(1)
qc.ry(theta, 0)
result = StatevectorEstimator().run([(qc, SparsePauliOp('Z'), [np.pi])]).result()
print(result[0].data.evs)
  • A. -1.0
  • B. 0.0
  • C. 1.0
  • D. It raises an error — the circuit has no measurements

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

Q26. Which code produced this text drawing?

          ┌───┐
q_0: ─────┤ X ├
     ┌───┐└─┬─┘
q_1: ┤ H ├──■──
  • A. qc.h(0); qc.cx(0, 1)
  • B. qc.h(1); qc.cx(0, 1)
  • C. qc.h(0); qc.cx(1, 0)
  • D. qc.h(1); qc.cx(1, 0)

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

  • A. Both arrows pointing to +Z
  • B. Qubit 0 on +X, qubit 1 on +Z
  • C. Both vectors have zero length (points at the center of each sphere)
  • D. The function raises an error because the state is entangled

Q28. A 2-qubit Sampler run returns {'01': 512, '10': 488} over 1000 shots. What is the estimated probability that qubit 1 is measured as 1?

  • A. 0.512
  • B. 0.488
  • C. 1.0
  • D. 0.0

Q29. Which visualization encodes the relative phase of each basis-state amplitude as a color?

  • A. plot_histogram
  • B. plot_bloch_multivector
  • C. plot_state_qsphere
  • D. plot_distribution

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

Q30. Yesterday you submitted a job whose ID is "d8a1b2c3". Today, in a fresh Python session, which snippet retrieves its result?

  • A.
    result = SamplerV2.retrieve_job("d8a1b2c3").result()
  • B.
    result = backend.retrieve_job("d8a1b2c3").result()
  • C.
    service = QiskitRuntimeService()
    result = service.job("d8a1b2c3").result()
  • D.
    result = QiskitRuntimeService.results("d8a1b2c3")

Q31. A single-qubit circuit yields {'0': 300, '1': 700} over 1000 shots. What is the estimated ⟨Z⟩?

  • A. -0.4
  • B. 0.4
  • C. 0.7
  • D. -0.7

Q32. Your Estimator run's standard error is twice as large as you need. Approximately how must the shot count change to halve the standard error?

  • A. Double it
  • B. Quadruple it
  • C. Halve it
  • D. Multiply it by √2

Section 8 — Operate with OpenQASM (Q33–Q34)

Q33. This OpenQASM 3 program is loaded with qiskit.qasm3.loads and executed for 1000 shots. What are the counts?

OPENQASM 3.0;
include "stdgates.inc";
qubit[2] q;
bit[2] c;
x q[0];
cx q[0], q[1];
c = measure q;
  • A. {'01': 1000}
  • B. {'10': 1000}
  • C. {'11': 1000}
  • D. {'00': 500, '11': 500}

Q34. Which snippet exports a QuantumCircuit qc to an OpenQASM 3 string?

  • A. qiskit.qasm3.dumps(qc)
  • B. qc.qasm()
  • C. qiskit.qasm3.dump(qc)
  • D. qiskit.qasm3.loads(qc)

End of Paper 07. Check your work against paper-07-answers.md.