Skip to content
Kartikey Purohit
← Course overview

Sample Papers

Paper 6

Fundamentals of Quantum Computing Using Qiskit v2.X Developer Flavor: visualization + OpenQASM reading — ASCII circuit diagrams and QASM programs to interpret.

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. In text drawings, q0 is the top wire unless reverse_bits=True is used.
  4. No notes, no interpreter. Time yourself. Answers are in paper-06-answers.md.

Section 1 — Create Quantum Circuits (Q1–Q6)

Q1. Which text drawing does this code produce?

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

Q2. What does this code print?

from qiskit import QuantumCircuit, QuantumRegister, AncillaRegister
 
q = QuantumRegister(2, 'q')
a = AncillaRegister(1, 'anc')
qc = QuantumCircuit(q, a)
print(qc.num_qubits, qc.num_ancillas)
  • A. 2 1
  • B. 2 3
  • C. 3 1
  • D. 3 0 — ancillas are not qubits until used

Q3. This drawing was produced by qc.draw('text') on a fresh QuantumCircuit(2):

     ┌───┐        
q_0: ┤ X ├─X──────
     └───┘ │ ┌───┐
q_1: ──────X─┤ H ├
             └───┘

Which code produced it?

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

Q4. What does this code print?

from qiskit import QuantumCircuit
 
qc = QuantumCircuit(2)
qc.h(0)
qc.barrier()
qc.x(1)
print(qc.depth(), qc.size())
  • A. 1 2 — the gates act on different qubits, so they share a layer
  • B. 2 2
  • C. 3 3 — the barrier adds a layer and an instruction
  • D. 2 3

Q5. You measure qubit 0 into clbit 0 mid-circuit and want to apply x(1) when the result is 1, and z(1) otherwise. Which v2.x construct expresses this?

  • A. qc.x(1).c_if(0, 1); qc.z(1).c_if(0, 0)
  • B. qc.if_test(0 == 1, qc.x, qc.z)
  • C. ```python with qc.if_test((qc.clbits[0], 1)) as else_: qc.x(1) with else_: qc.z(1)
  • D. qc.switch(qc.clbits[0], x=1, z=0)

Q6. Given:

a = QuantumCircuit(1); a.h(0)
b = QuantumCircuit(2); b.cx(0, 1)
c = a.tensor(b)

Which statement about c is true?

  • A. It raises an error — tensor requires equal circuit widths
  • B. c has 2 qubits; the H is merged onto b's qubit 0
  • C. c has 3 qubits and the H acts on qubit 0
  • D. c has 3 qubits and the H acts on qubit 2 — the argument circuit occupies the lower-indexed qubits

Section 2 — Perform Quantum Operations (Q7–Q12)

Q7. After this code, where does the qubit's state point on the Bloch sphere?

from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
 
qc = QuantumCircuit(1)
qc.h(0)
qc.s(0)
sv = Statevector.from_instruction(qc)
  • A. +x axis
  • B. +y axis
  • C. −z axis
  • D. −x axis

Q8. What does this code print?

from qiskit.quantum_info import Pauli
 
print(Pauli('X').commutes(Pauli('Z')), Pauli('XX').commutes(Pauli('ZZ')))
  • A. False True
  • B. False False
  • C. True True
  • D. True False

Q9. What does this code print (to two decimals)?

from qiskit.quantum_info import Statevector, state_fidelity
 
print(state_fidelity(Statevector.from_label('+'), Statevector.from_label('0')))
  • A. 0.71
  • B. 1.0
  • C. 0.5
  • D. 0.0

Q10. Which snippet prepares |−⟩ = (|0⟩ − |1⟩)/√2 on a fresh single-qubit circuit?

  • A. qc.h(0); qc.x(0)
  • B. qc.z(0); qc.h(0)
  • C. qc.h(0); qc.s(0)
  • D. qc.x(0); qc.h(0)

Q11. What does this code print (up to float rounding)?

from qiskit import QuantumCircuit
from qiskit.quantum_info import Pauli, Statevector
 
qc = QuantumCircuit(3)
qc.h(0)
qc.cx(0, 1)
qc.cx(1, 2)
sv = Statevector.from_instruction(qc)
print(sv.expectation_value(Pauli('ZZI')), sv.expectation_value(Pauli('IIZ')))
  • A. 1.0 0.0
  • B. 0.0 1.0
  • C. 1.0 1.0
  • D. 0.0 0.0

Q12. How do the gates rz(π) and z on the same qubit compare?

  • A. They are different operators and give different measurement statistics in every basis
  • B. They differ only by a global phase, so all measurement statistics are identical
  • C. They are equal as matrices
  • D. rz(π) equals Z only when applied to |0⟩ or |1⟩

Section 3 — Run Quantum Circuits (Q13–Q17)

Q13. You construct sampler = SamplerV2(mode=backend) passing a backend object directly. Which execution mode is used?

  • A. Job mode — each run() call is an independent queued job
  • B. Session mode — a session is opened implicitly
  • C. Batch mode — jobs are grouped automatically
  • D. Local mode — passing a backend object only works with simulators

Q14. For local, no-account testing of Runtime-style code against a noisy 5-qubit device model, which import is appropriate?

  • A. from qiskit_ibm_runtime import LocalBackend
  • B. from qiskit_aer import FakeManilaV2
  • C. from qiskit_ibm_runtime.fake_provider import FakeManilaV2
  • D. from qiskit.providers import FakeManilaV2

Q15. You must run 20 independent transpiled circuits and want them scheduled efficiently together without paying per-job queue waits, and no classical feedback between them. Which mode?

  • A. Session mode
  • B. Batch mode
  • C. Job mode, submitted in a loop
  • D. Estimator mode

Q16. What does this code print?

import numpy as np
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
from qiskit.primitives import StatevectorSampler
 
theta = Parameter('t')
qc = QuantumCircuit(1, 1)
qc.rx(theta, 0)
qc.measure(0, 0)
job = StatevectorSampler().run([(qc, [np.pi])], shots=100)
print(job.result()[0].data.c.get_counts())
  • A. Roughly {'0': 50, '1': 50}
  • B. {'0': 100}
  • C. It raises an error — parameters must be bound with assign_parameters before running
  • D. {'1': 100}

Q17. A Sampler has options.default_shots = 1024, run() is called with shots=2048, and one PUB specifies shots=4096 as its third element. How many shots does that PUB get?

  • A. 4096 — the per-PUB value has the highest precedence
  • B. 2048 — the run() argument always wins
  • C. 1024 — options override everything
  • D. 7168 — the values accumulate

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()
r = StatevectorSampler().run([qc], shots=100).result()[0]
bs = r.data.meas.get_bitstrings()
print(len(bs), bs[0])
  • A. 2 '01'
  • B. 100 '01'
  • C. 100 '10'
  • D. 2 '10'

Q19. A circuit with H and CX gates but no measurements is submitted to SamplerV2. What happens?

  • A. It runs and returns the exact statevector probabilities
  • B. It runs and returns an empty DataBin
  • C. It raises an error — the Sampler requires classical output (measurements) in the circuit
  • D. Measurements of all qubits are appended automatically

Q20. Which snippet correctly enables dynamical decoupling with the XY4 sequence on a Runtime Sampler?

  • A. sampler.options.resilience.dynamical_decoupling = "XY4"
  • B. ```python sampler.options.dynamical_decoupling.enable = True sampler.options.dynamical_decoupling.sequence_type = "XY4"
  • C. sampler.run(pubs, dynamical_decoupling="XY4")
  • D. sampler.options.twirling.enable_gates = "XY4"

Q21. What does this code print?

from qiskit import QuantumCircuit
from qiskit.primitives import StatevectorSampler
 
qc = QuantumCircuit(1)
qc.h(0)
qc.measure_all()
r = StatevectorSampler().run([qc], shots=10).result()[0]
print(r.data.c.get_counts())
  • A. Roughly {'0': 5, '1': 5}
  • B. {'0': 10}
  • C. It prints an empty dict — the register c exists but is never written
  • D. It raises AttributeErrormeasure_all() stores results under data.meas, not data.c

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

Q22. What does this code print (up to float rounding)?

import numpy as np
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
from qiskit.primitives import StatevectorEstimator
from qiskit.quantum_info import SparsePauliOp
 
theta = Parameter('t')
qc = QuantumCircuit(1)
qc.ry(theta, 0)
obs = SparsePauliOp('Z')
res = StatevectorEstimator().run([(qc, obs, [[0.0], [np.pi/2], [np.pi]])]).result()
print(res[0].data.evs)
  • A. [ 1. 0. -1.]
  • B. [ 0. 1. 0.]
  • C. [-1. 0. 1.]
  • D. [ 1. 0.5 0.]

Q23. Why must a circuit sent to the Estimator contain no measurement instructions?

  • A. Measurements are appended automatically from the coupling map
  • B. Measurements are allowed but silently ignored
  • C. The observable itself defines what is measured; explicit measurements are invalid input for expectation-value estimation
  • D. Measurements are required — this premise is false

Q24. You want each expectation value estimated to a target precision of 0.01. Which call is correct?

  • A. estimator.options.default_shots = 0.01
  • B. estimator.run([(isa_qc, obs)], precision=0.01)
  • C. estimator.run([(isa_qc, obs)], shots=0.01)
  • D. estimator.options.resilience_level = 0.01

Q25. (Choose TWO.) Which of these techniques are error mitigation (classical post-processing of results) rather than error suppression (applied before/during execution)?

  • A. Zero-noise extrapolation (ZNE)
  • B. Dynamical decoupling
  • C. Pauli twirling
  • D. Measurement error mitigation (TREX)

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

Q26. Which code produces this drawing?

        ┌───┐      ░ ┌─┐   
   q_0: ┤ H ├──■───░─┤M├───
        └───┘┌─┴─┐ ░ └╥┘┌─┐
   q_1: ─────┤ X ├─░──╫─┤M├
             └───┘ ░  ║ └╥┘
meas: 2/══════════════╩══╩═
                      0  1 
  • A. ```python qc = QuantumCircuit(2) qc.h(0) qc.cx(0, 1) qc.measure_all()
  • B. ```python qc = QuantumCircuit(2, 2) qc.h(0) qc.cx(0, 1) qc.measure([0, 1], [0, 1])
  • C. ```python qc = QuantumCircuit(2) qc.h(1) qc.cx(1, 0) qc.measure_all()
  • D. ```python qc = QuantumCircuit(2) qc.h(0) qc.cx(0, 1) qc.barrier() qc.measure_active()

Q27. plot_bloch_multivector is called on the two-qubit state (|00⟩ + |11⟩)/√2. What is shown?

  • A. Both arrows along +x
  • B. q0 along +z, q1 along −z
  • C. Both arrows along +z
  • D. Both arrows have zero length — entangled qubits have no individual Bloch vector

Q28. Which drawing does this code produce?

from qiskit import QuantumCircuit
 
qc = QuantumCircuit(2)
qc.x(0)
print(qc.draw('text', reverse_bits=True))
  • A. ```text ┌───┐ q_0: ┤ X ├ └───┘ q_1: ─────

  • B. ```text ┌───┐ q_1: ┤ X ├ └───┘ q_0: ─────

  • C. ```text

    q_1: ───── ┌───┐ q_0: ┤ X ├ └───┘

  • D. ```text

    q_0: ───── ┌───┐ q_1: ┤ X ├ └───┘

Q29. On a plot_state_qsphere rendering of (|0⟩ − |1⟩)/√2, the |1⟩ blob has a different color from the |0⟩ blob. What does that color difference represent?

  • A. The |1⟩ amplitude is smaller
  • B. The relative phase of π on the |1⟩ amplitude
  • C. Measurement error on the |1⟩ outcome
  • D. The Hamming weight of the label

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

Q30. A Sampler job over 1000 shots returns {'00': 512, '11': 488}. What is the estimated probability of outcome '11'?

  • A. 0.512
  • B. 488
  • C. 0.488
  • D. 0.5 — the ideal Bell value must be reported

Q31. Immediately after job = sampler.run(pubs) returns, the Python program continues executing. Which pair of statements about this job is correct?

  • A. run() is asynchronous; you can check job.status() now and retrieve the same job later via service.job(job.job_id())
  • B. run() blocks until completion; job.result() is just a cached accessor
  • C. run() is asynchronous, but results are lost when the Python process exits
  • D. run() returns the PrimitiveResult directly; there is no job object

Q32. After a Runtime job completes, which call tells you how much QPU time the job consumed?

  • A. job.result().metadata['duration']
  • B. job.qpu_seconds()
  • C. len(job.metrics())
  • D. job.usage()

Section 8 — Operate with OpenQASM (Q33–Q34)

Q33. This OpenQASM 3 program is loaded with qasm3.loads and run on an ideal Sampler with 100 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];
x q[0];
c = measure q;
  • A. {'01': 100}
  • B. {'10': 100}
  • C. {'11': 100}
  • D. {'00': 100}

Q34. This OpenQASM 2 program is imported with QuantumCircuit.from_qasm_str and executed on an ideal simulator with many shots. Which bitstrings appear in the counts?

OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
creg c[3];
h q[0];
cx q[0], q[1];
measure q -> c;
  • A. '000' and '110', about 50/50
  • B. '000' and '111', about 50/50
  • C. '000' and '011', about 50/50
  • D. '011' only

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