Title: CertiQ — C1000-179 / 3 · Create quantum circuits

Question: The circuit below flips only qubit 0 of a 3-qubit register and then measures every qubit with measure_all(). Running it on the default AerSimulator, which single bitstring is returned for every shot?
from qiskit import QuantumCircuit
qc = QuantumCircuit(3)
qc.x(0)
qc.measure_all()
A.100
B.010
C.001
D.111
Answer: Correct: C
Qiskit prints bitstrings in little-endian order: the rightmost character is the classical bit holding qubit 0, and the index increases leftward. Only qubit 0 is excited, so the outcome is 001 (q2 q1 q0 = 0 0 1).
References
- quantum.cloud.ibm.com/docs/guides/construct-circuits
- quantum.cloud.ibm.com/docs/guides/measure-qubits
Meta: s3-q010 · predict-output · Difficulty 1/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: A 2-qubit circuit is created with QuantumCircuit(2) (no classical register). Which statement correctly describes what qc.measure_all() does to it?
from qiskit import QuantumCircuit
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()
A.It raises an error because the circuit has no classical bits to measure into.
B.It adds a new 2-bit classical register named meas plus a barrier, then measures each qubit into the matching new bit.
C.It adds 2 classical bits to a register named c and inserts no barrier.
D.It measures only qubits that already carry gates, adding a single classical bit.
Answer: Correct: B
measure_all() creates a fresh ClassicalRegister named meas sized to the number of qubits, inserts a barrier across all qubits, and measures qubit i into meas[i]. It is the convenient one-call way to read out an entire circuit.
References
- quantum.cloud.ibm.com/docs/guides/construct-circuits
- quantum.cloud.ibm.com/docs/guides/measure-qubits
Meta: s3-q011 · mcq · Difficulty 1/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: sub (a 2-qubit circuit whose only gate is cx(0, 1)) is composed onto the 3-qubit circuit qc with the mapping qubits=[0, 2]. In the resulting circuit comp, which qubits does the CX act on?
from qiskit import QuantumCircuit
qc = QuantumCircuit(3)
qc.h(0)
sub = QuantumCircuit(2)
sub.cx(0, 1)
comp = qc.compose(sub, qubits=[0, 2])
A.Control = qubit 0, target = qubit 1
B.Control = qubit 1, target = qubit 2
C.Control = qubit 0, target = qubit 2
D.compose raises an error because sub has fewer qubits than qc
Answer: Correct: C
compose(sub, qubits=[0, 2]) maps sub's qubit 0 to qc's qubit 0 and sub's qubit 1 to qc's qubit 2. The CX sub.cx(0, 1) therefore becomes a CX with control qubit 0 and target qubit 2 in comp.
References
- quantum.cloud.ibm.com/docs/guides/construct-circuits
- quantum.cloud.ibm.com/docs/api/qiskit/qiskit.circuit.QuantumCircuit
Meta: s3-q012 · predict-output · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: A developer expects base to contain its H followed by the X from add_on, but after this code base still shows only the H gate. What is the bug and the correct fix?
from qiskit import QuantumCircuit
base = QuantumCircuit(1)
base.h(0)
add_on = QuantumCircuit(1)
add_on.x(0)
base.compose(add_on)   # intended to append X onto base
print(base.count_ops())
A.compose cannot be used for single-qubit gates; base.append must be used instead.
B.compose returns a new circuit and does not modify base in place; fix with base = base.compose(add_on) or base.compose(add_on, inplace=True).
C.add_on must be converted with add_on.to_gate() before it can be composed.
D.base needs a classical register before compose takes effect.
Answer: Correct: B
By default compose is functional: it RETURNS a new circuit and leaves the caller untouched (inplace=False). Discarding the return value loses the X. Assign the result back, or pass inplace=True to mutate base.
References
- quantum.cloud.ibm.com/docs/guides/construct-circuits
- quantum.cloud.ibm.com/docs/api/qiskit/qiskit.circuit.QuantumCircuit
Meta: s3-q013 · spot-bug · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: You want a circuit with a 2-qubit register q and a 2-bit register c, both qubits in superposition, measuring q[i] into c[i]. Which snippet builds AND runs on AerSimulator without raising, producing 2-bit outcomes?
A.qc=QuantumCircuit(2); qc.h([0,1]); qc.measure([0,1],[0,1])
B.q=QuantumRegister(2,'q'); qc=QuantumCircuit(q); qc.h(q); qc.measure(q,q)
C.q=QuantumRegister(2,'q'); c=ClassicalRegister(2,'c'); qc=QuantumCircuit(q,c); qc.h(q); qc.measure(c,q)
D.q=QuantumRegister(2,'q'); c=ClassicalRegister(2,'c'); qc=QuantumCircuit(q,c); qc.h(q[0]); qc.h(q[1]); qc.measure(q[0],c[0]); qc.measure(q[1],c[1])
Answer: Correct: D
You must declare classical bits before measuring into them. Option D creates both registers, passes them to QuantumCircuit, and calls measure(qubit, clbit) in the correct argument order, so it builds and runs, giving 2-bit outcomes.
References
- quantum.cloud.ibm.com/docs/guides/construct-circuits
- quantum.cloud.ibm.com/docs/guides/measure-qubits
Meta: s3-q014 · mcq · Difficulty 1/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: Consider the circuit below. Select ALL statements that are TRUE about its structural properties. (Recall width() counts qubits + classical bits.)
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
qr = QuantumRegister(3, 'q')
cr = ClassicalRegister(2, 'c')
qc = QuantumCircuit(qr, cr)
qc.h(0)
qc.cx(0, 1)
qc.cx(1, 2)
qc.measure(0, 0)
qc.measure(2, 1)
A.The circuit has 3 qubits and 2 classical bits.
B.qc.width() returns 3.
C.qc.size() returns 5 (the total number of operations).
D.qc.depth() equals qc.size().
E.qc.num_qubits + qc.num_clbits equals qc.width().
Answer: Correct: A, C, E
num_qubits=3 and num_clbits=2 (A). size() counts all 5 operations: 1 H + 2 CX + 2 measures (C). width() returns qubits + classical bits = 3 + 2 = 5, so it equals num_qubits + num_clbits (E).
References
- quantum.cloud.ibm.com/docs/guides/construct-circuits
- quantum.cloud.ibm.com/docs/api/qiskit/qiskit.circuit.QuantumCircuit
Meta: s3-q015 · multi · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: The circuit prepares a 3-qubit state. Which computational-basis states have non-zero amplitude in its statevector, and with what amplitude?
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
qc = QuantumCircuit(3)
qc.h(0)
qc.cx(0, 1)
qc.cx(0, 2)
sv = Statevector(qc)
A.|000⟩ and |111⟩, each with amplitude 1/√2 (a GHZ state).
B.|000⟩ and |100⟩, each with amplitude 1/√2.
C.All eight basis states, each with amplitude 1/√8.
D.|000⟩ and |011⟩, each with amplitude 1/√2.
Answer: Correct: A
H on qubit 0 makes (|0⟩+|1⟩)/√2. The two CX gates copy qubit 0's value onto qubits 1 and 2, so the state becomes (|000⟩ + |111⟩)/√2 — a 3-qubit GHZ state with only those two basis states populated.
References
- quantum.cloud.ibm.com/docs/guides/construct-circuits
- quantum.cloud.ibm.com/docs/api/qiskit/quantum_info
Meta: s3-q016 · predict-output · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: A list of values is passed to assign_parameters. What angles do the rx and rz gates end up with?
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
theta = Parameter('theta')
phi = Parameter('phi')
qc = QuantumCircuit(1)
qc.rx(theta, 0)   # added first
qc.rz(phi, 0)     # added second
bound = qc.assign_parameters([0.5, 1.5])
A.rx = 0.5, rz = 1.5 — the list is applied in the order the gates were added.
B.rx = 0.5, rz = 0.5 — both gates receive the first value.
C.It raises an error: assign_parameters requires a dictionary, not a list.
D.rx = 1.5, rz = 0.5 — the list is applied in alphabetical parameter order (phi, then theta).
Answer: Correct: D
When you pass a plain list, values are bound to qc.parameters, which is sorted ALPHABETICALLY by name — phi before theta. So phi=0.5 and theta=1.5, giving rz(phi)=0.5 and rx(theta)=1.5. Insertion order is irrelevant.
References
- quantum.cloud.ibm.com/docs/guides/construct-circuits
- quantum.cloud.ibm.com/docs/api/qiskit/qiskit.circuit.Parameter
Meta: s3-q017 · predict-output · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: Three parameters are created and added to a circuit in the order gamma, alpha, beta. What does [p.name for p in qc.parameters] return?
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
g = Parameter('gamma'); a = Parameter('alpha'); b = Parameter('beta')
qc = QuantumCircuit(1)
qc.rz(g, 0)
qc.rx(a, 0)
qc.ry(b, 0)
print([p.name for p in qc.parameters])
A.['alpha', 'beta', 'gamma'] — sorted alphabetically by name.
B.['gamma', 'alpha', 'beta'] — the order the parameters were added.
C.['beta', 'alpha', 'gamma'] — reverse insertion order.
D.The order is unspecified and can vary between runs.
Answer: Correct: A
QuantumCircuit.parameters returns a ParameterView sorted alphabetically by parameter name, so it is ['alpha', 'beta', 'gamma']. This deterministic ordering is exactly why passing a bare list to assign_parameters can surprise you.
References
- quantum.cloud.ibm.com/docs/guides/construct-circuits
- quantum.cloud.ibm.com/docs/api/qiskit/qiskit.circuit.Parameter
Meta: s3-q018 · mcq · Difficulty 1/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: This code is meant to bind both parameters but raises a ValueError. What is the problem and the correct fix?
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
a = Parameter('a'); b = Parameter('b')
qc = QuantumCircuit(1)
qc.rx(a, 0)
qc.rz(b, 0)
bound = qc.assign_parameters([0.7])   # intended to bind a and b
A.assign_parameters only accepts a dictionary; a list is never allowed.
B.A list must provide a value for EVERY parameter; supply [0.7, <b_value>], or use a dict like {a: 0.7} for partial binding.
C.Parameters must be bound individually with gate.assign().
D.The circuit must be transpiled before any parameters can be assigned.
Answer: Correct: B
A list binds positionally to ALL of qc.parameters, so its length must equal the number of parameters (2 here). Passing one value raises ValueError. Provide both values in a list, or pass a dict to bind a subset.
References
- quantum.cloud.ibm.com/docs/guides/construct-circuits
- quantum.cloud.ibm.com/docs/api/qiskit/qiskit.circuit.Parameter
Meta: s3-q019 · spot-bug · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: After this binding step, which statement about qc and bound is correct?
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
theta = Parameter('theta')
qc = QuantumCircuit(1)
qc.rx(theta, 0)
bound = qc.assign_parameters({theta: 3.14})
A.qc is now fully bound (0 free parameters), and bound is the same object as qc.
B.assign_parameters returns None; the bound circuit must be read back from qc.
C.qc still has 1 free parameter, and bound is a new circuit with 0 free parameters.
D.Both qc and bound have 0 free parameters, because assign_parameters mutates in place by default.
Answer: Correct: C
assign_parameters is functional by default (inplace=False): it returns a NEW circuit with the values substituted and leaves the original untouched. So qc keeps its 1 free parameter while bound has 0.
References
- quantum.cloud.ibm.com/docs/guides/construct-circuits
- quantum.cloud.ibm.com/docs/api/qiskit/qiskit.circuit.Parameter
Meta: s3-q020 · mcq · Difficulty 1/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: The gates use parameter EXPRESSIONS. After binding t = π, what numeric angles do rx and rz receive?
import numpy as np
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
t = Parameter('t')
qc = QuantumCircuit(1)
qc.rx(2 * t, 0)
qc.rz(t + np.pi / 2, 0)
bound = qc.assign_parameters({t: np.pi})
A.rx = 2π ≈ 6.283, rz = 3π/2 ≈ 4.712.
B.rx = π ≈ 3.142, rz = π ≈ 3.142 — the expressions are ignored and t is substituted directly.
C.rx = 2π ≈ 6.283, rz = π/2 ≈ 1.571 — only the coefficient is applied; the added constant is dropped.
D.It raises an error because gate angles must be plain Parameters, not expressions.
Answer: Correct: A
Parameter expressions are evaluated at bind time. With t = π: 2*t = 2π ≈ 6.283, and t + π/2 = 3π/2 ≈ 4.712. Qiskit fully supports arithmetic on Parameter objects inside gate arguments.
References
- quantum.cloud.ibm.com/docs/guides/construct-circuits
- quantum.cloud.ibm.com/docs/api/qiskit/qiskit.circuit.Parameter
Meta: s3-q021 · predict-output · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: A circuit is built with a ParameterVector. Select ALL true statements.
from qiskit import QuantumCircuit
from qiskit.circuit import ParameterVector
x = ParameterVector('x', 3)
qc = QuantumCircuit(3)
for i in range(3):
    qc.ry(x[i], i)
A.qc.num_parameters is 3.
B.The parameters are named x[0], x[1], x[2].
C.qc.assign_parameters({x: [0.1, 0.2, 0.3]}) binds the entire vector in one call.
D.x[0] and x[1] are the same Parameter object.
E.A ParameterVector can only be bound one element at a time, never as a whole.
Answer: Correct: A, B, C
A ParameterVector('x', 3) creates 3 distinct parameters named x[0..2] (A, B). You can bind the whole vector at once by using it as a single dict key mapped to a list of values (C).
References
- quantum.cloud.ibm.com/docs/guides/construct-circuits
- quantum.cloud.ibm.com/docs/api/qiskit/qiskit.circuit.ParameterVector
Meta: s3-q022 · multi · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: This dynamic circuit measures qubit 0 and, only if that result is 1, applies X to qubit 1; then it measures qubit 1. Over many shots (bit order c1 c0), which outcomes appear?
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
qr = QuantumRegister(2, 'q')
cr = ClassicalRegister(2, 'c')
qc = QuantumCircuit(qr, cr)
qc.h(0)
qc.measure(0, 0)
with qc.if_test((cr[0], 1)):
    qc.x(1)
qc.measure(1, 1)
A.Only 01 and 00, roughly 50/50.
B.All four of 00, 01, 10, 11, roughly 25% each.
C.Only 10 and 11, roughly 50/50.
D.Only 00 and 11, roughly 50/50 — qubit 1 always ends up matching qubit 0.
Answer: Correct: D
The H puts qubit 0 into an equal superposition, so its measurement c0 is 0 or 1 with ~50% each. The feedforward flips qubit 1 exactly when c0=1, so c1 always equals c0. The only outcomes are 00 and 11.
References
- quantum.cloud.ibm.com/docs/guides/classical-feedforward-and-control-flow
- quantum.cloud.ibm.com/docs/guides/construct-circuits
Meta: s3-q023 · predict-output · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: After measuring qubit 0 into cr[0], you want to apply X to qubit 1 only when that bit equals 1. Which snippet is valid in Qiskit 2.x and produces a conditional (if_else) operation?
# qr = QuantumRegister(2,'q'); cr = ClassicalRegister(2,'c')
# qc has already done: qc.h(0); qc.measure(0, 0)
A.qc.x(1).c_if(cr[0], 1)
B.with qc.if_test(cr[0], 1): qc.x(1)
C.with qc.if_test((cr[0], 1)): qc.x(1)
D.qc.if_test((cr[0], 1), qc.x, [1])
Answer: Correct: C
The modern control-flow API is a context manager whose single argument is a (classical_resource, value) TUPLE: with qc.if_test((cr[0], 1)):. Gates added inside the block become the conditional body, producing an if_else operation.
References
- quantum.cloud.ibm.com/docs/guides/classical-feedforward-and-control-flow
- quantum.cloud.ibm.com/docs/api/qiskit/qiskit.circuit.QuantumCircuit
Meta: s3-q024 · mcq · Difficulty 1/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: This conditional code was written for an older Qiskit release and now fails with AttributeError on Qiskit 2.x. What is the correct fix?
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
qr = QuantumRegister(1, 'q')
cr = ClassicalRegister(1, 'c')
qc = QuantumCircuit(qr, cr)
qc.h(0)
qc.measure(0, 0)
qc.x(0).c_if(cr, 1)   # AttributeError on Qiskit 2.x
A.Replace it with a context manager: with qc.if_test((cr, 1)): then qc.x(0). .c_if() was removed in Qiskit 2.0.
B.Change c_if(cr, 1) to c_if(cr[0], 1); the condition must reference a single bit.
C.Call qc = qc.decompose() before the conditional so .c_if() becomes available.
D.Use qc.x(0, condition=(cr, 1)); the condition keyword replaces .c_if().
Answer: Correct: A
The InstructionSet.c_if method was removed in Qiskit 2.0. Conditionals are now built with the control-flow context manager with qc.if_test((cr, 1)):, whose body holds the conditioned gates.
References
- quantum.cloud.ibm.com/docs/guides/classical-feedforward-and-control-flow
- quantum.cloud.ibm.com/docs/api/qiskit/qiskit.circuit.QuantumCircuit
Meta: s3-q025 · spot-bug · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: This dynamic circuit branches on cr[0]: if it is 0 it applies X to qubit 1, ELSE it applies Z to qubit 1; then it measures qubit 1. Which outcomes appear (bit order c1 c0)?
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
qr = QuantumRegister(2, 'q')
cr = ClassicalRegister(2, 'c')
qc = QuantumCircuit(qr, cr)
qc.h(0)
qc.measure(0, 0)
with qc.if_test((cr[0], 0)) as else_:
    qc.x(1)
with else_:
    qc.z(1)
qc.measure(1, 1)
A.Only 00 and 11, roughly 50/50.
B.Only 10 and 01, roughly 50/50.
C.Only 11 and 01, roughly 50/50.
D.All four outcomes, roughly 25% each.
Answer: Correct: B
When c0=0 the X flips qubit 1 to |1⟩, so c1=1 → 10. When c0=1 the Z acts on |0⟩ and leaves it unchanged, so c1=0 → 01. The two branches give 10 and 01, each ~50%.
References
- quantum.cloud.ibm.com/docs/guides/classical-feedforward-and-control-flow
- quantum.cloud.ibm.com/docs/guides/construct-circuits
Meta: s3-q026 · predict-output · Difficulty 3/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: Which scenario genuinely REQUIRES a dynamic circuit (a mid-circuit measurement whose classical result feeds forward to control a later gate), rather than a plain static circuit?
A.Applying a fixed sequence of gates to all qubits and measuring only at the very end.
B.Sweeping a rotation angle across many values to plot an expectation curve.
C.Reducing two-qubit gate count by letting the transpiler cancel adjacent gates.
D.Measuring an ancilla mid-circuit and applying a correction gate to a data qubit only when that measurement is 1.
Answer: Correct: D
Dynamic circuits exist precisely for real-time classical feedforward: measure a qubit partway through, then condition subsequent quantum operations on that classical outcome (as in teleportation corrections or error-correction syndrome handling). Option D is exactly that pattern.
References
- quantum.cloud.ibm.com/docs/guides/classical-feedforward-and-control-flow
- quantum.cloud.ibm.com/docs/guides/construct-circuits
Meta: s3-q027 · mcq · Difficulty 1/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: The for_loop below repeats its body over range(3), applying X to qubit 0 three times, then measures. What does the measurement return?
from qiskit import QuantumCircuit
qc = QuantumCircuit(1, 1)
with qc.for_loop(range(3)):
    qc.x(0)
qc.measure(0, 0)
A.Always 0 — the repeated X gates cancel out to the identity.
B.It raises an error because for_loop requires a classical register argument.
C.Always 1 — X is applied an odd number of times (3), flipping |0⟩ to |1⟩.
D.0 and 1 with roughly 50% probability each.
Answer: Correct: C
The loop body runs 3 times, so X is applied 3 times. Three X gates equal a single X (odd count), flipping |0⟩ to |1⟩, so every shot measures 1.
References
- quantum.cloud.ibm.com/docs/guides/classical-feedforward-and-control-flow
- quantum.cloud.ibm.com/docs/guides/construct-circuits
Meta: s3-q028 · predict-output · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: Select ALL statements that correctly describe control flow in Qiskit 2.x.
A.if_test is used as a context manager whose condition is a (classical_resource, value) tuple.
B..c_if() is still available on gate instructions as the recommended way to add a conditional.
C.Control-flow blocks such as if_else and for_loop appear as single operations in count_ops().
D.A for_loop body may contain at most one gate.
E.A switch block can define a fallback branch using case(case.DEFAULT).
Answer: Correct: A, C, E
if_test((resource, value)) is the context-manager API (A). Each control-flow block is stored as one composite instruction, so count_ops() shows if_else, for_loop, etc. (C). switch supports a default branch via case(case.DEFAULT) (E).
References
- quantum.cloud.ibm.com/docs/guides/classical-feedforward-and-control-flow
- quantum.cloud.ibm.com/docs/api/qiskit/qiskit.circuit.QuantumCircuit
Meta: s3-q029 · multi · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: You build pm = generate_preset_pass_manager(optimization_level=2, backend=backend), which returns a StagedPassManager. What are its stages, in execution order?
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
pm = generate_preset_pass_manager(optimization_level=2, backend=backend)
print(pm.stages)
A.('layout', 'routing', 'translation', 'optimization') — four stages.
B.('init', 'layout', 'routing', 'optimization', 'measurement').
C.('sampling', 'layout', 'routing', 'translation', 'scheduling').
D.('init', 'layout', 'routing', 'translation', 'optimization', 'scheduling') — six stages.
Answer: Correct: D
A preset StagedPassManager runs six stages in order: init, layout, routing, translation, optimization, and scheduling. Layout+routing map the circuit to hardware qubits/connectivity, translation rewrites to the basis gates, optimization simplifies, and scheduling adds timing.
References
- quantum.cloud.ibm.com/docs/guides/transpiler-stages
- quantum.cloud.ibm.com/docs/guides/transpile-with-pass-managers
Meta: s3-q030 · mcq · Difficulty 1/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: In Qiskit 2.x, you call generate_preset_pass_manager(backend=backend) WITHOUT passing optimization_level. Which optimization level does it use by default?
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
pm = generate_preset_pass_manager(backend=backend)   # no optimization_level given
A.0
B.2
C.1
D.3
Answer: Correct: B
generate_preset_pass_manager defaults to optimization_level=2 — a balanced level with light-weight but effective optimization. (Note this differs from the older transpile() function, whose default resolves to level 1.)
References
- quantum.cloud.ibm.com/docs/guides/set-optimization
- quantum.cloud.ibm.com/docs/guides/transpile-with-pass-managers
Meta: s3-q031 · mcq · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: A circuit whose only gate is cx(0, 4) is transpiled onto a 5-qubit LINE backend (connectivity 0-1-2-3-4, so qubits 0 and 4 are NOT directly connected). Comparing optimization_level=0 with optimization_level=1, what happens to the number of CX gates?
from qiskit import QuantumCircuit
from qiskit.transpiler import CouplingMap
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit.providers.fake_provider import GenericBackendV2
backend = GenericBackendV2(5, coupling_map=CouplingMap.from_line(5), seed=1)
qc = QuantumCircuit(5)
qc.cx(0, 4)
for lvl in (0, 1):
    isa = generate_preset_pass_manager(optimization_level=lvl,
                                       backend=backend, seed_transpiler=1).run(qc)
    print(lvl, isa.count_ops())
A.Level 0 needs many CX gates (it keeps the trivial layout and routes with SWAPs), while level 1 chooses a layout placing the two qubits adjacently, needing just one CX.
B.Both levels produce exactly one CX; the optimization level does not influence qubit layout.
C.Level 0 produces one CX; level 1 inserts SWAPs and ends up with more CX gates.
D.Both levels raise an error because a CX between non-adjacent qubits cannot be routed on a line.
Answer: Correct: A
At level 0 the layout is trivial (virtual qubit i -> physical qubit i), so the CX between physical 0 and 4 must be routed with SWAPs, decomposed into many CX gates. At level 1 the layout pass picks two adjacent physical qubits for the interacting virtual qubits, so a single CX suffices. This is why layout/optimization level dramatically affects gate count.
References
- quantum.cloud.ibm.com/docs/guides/set-optimization
- quantum.cloud.ibm.com/docs/guides/transpiler-stages
Meta: s3-q032 · predict-output · Difficulty 3/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: A backend's target has basis gates {cx, rz, sx, x} on a linear coupling map (qubit i connected only to i-1 and i+1). Which circuit is ALREADY an ISA circuit for this backend — needing no further transpilation?
A.A circuit using only rz, sx, and cx, with every cx acting on a physically-adjacent qubit pair.
B.A circuit that applies an h gate to qubit 0.
C.A circuit with a cx between qubit 0 and qubit 4 (not adjacent on the line).
D.A circuit containing a ccx (Toffoli) gate.
Answer: Correct: A
An ISA (Instruction Set Architecture) circuit uses ONLY the backend's basis gates AND respects its coupling map. Option A satisfies both: rz/sx/cx are in the basis and each cx is on connected qubits, so no translation or routing is needed.
References
- quantum.cloud.ibm.com/docs/guides/transpile
- quantum.cloud.ibm.com/docs/guides/transpiler-stages
Meta: s3-q033 · mcq · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: This code transpiles a 4-qubit circuit for a 3-qubit backend and raises a TranspilerError. What is the root cause?
from qiskit import QuantumCircuit
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit.providers.fake_provider import GenericBackendV2
backend = GenericBackendV2(num_qubits=3, seed=42)
qc = QuantumCircuit(4)
qc.h(range(4))
qc.measure_all()
pm = generate_preset_pass_manager(optimization_level=1, backend=backend)
isa = pm.run(qc)   # raises TranspilerError
A.measure_all() must be called AFTER transpilation, not before.
B.The circuit uses 4 qubits but the backend has only 3 — a circuit cannot be mapped onto a device with fewer qubits.
C.optimization_level=1 is too low to map 4 qubits; raising it to level 3 fixes it.
D.GenericBackendV2 must be constructed with an explicit coupling_map or transpilation always fails.
Answer: Correct: B
Transpilation maps each virtual qubit onto a distinct physical qubit. With 4 virtual qubits and only 3 physical qubits, no valid layout exists, so the layout stage raises TranspilerError: Number of qubits greater than device. The fix is a backend with at least 4 qubits.
References
- quantum.cloud.ibm.com/docs/guides/transpile
- quantum.cloud.ibm.com/docs/guides/set-optimization
Meta: s3-q034 · spot-bug · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: You have no backend object, but you know the target's basis gates ['cx','rz','sx','x'] and its coupling map cmap. Which call builds a pass manager that transpiles qc into an ISA circuit for that target?
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
# cmap is a CouplingMap; qc is an abstract circuit containing an h gate
basis = ['cx', 'rz', 'sx', 'x']
A.generate_preset_pass_manager(optimization_level=1).run(qc) — the basis and coupling map are inferred automatically.
B.transpile(qc) with no other arguments already returns an ISA circuit.
C.generate_preset_pass_manager(1, backend='ibm_target') using the target's name as a string.
D.generate_preset_pass_manager(optimization_level=1, basis_gates=basis, coupling_map=cmap).run(qc).
Answer: Correct: D
You can transpile without a backend object by passing the target constraints directly: basis_gates and coupling_map (and/or a Target). The pass manager then translates gates to the basis and routes to the connectivity, yielding an ISA circuit.
References
- quantum.cloud.ibm.com/docs/guides/transpile-with-pass-managers
- quantum.cloud.ibm.com/docs/guides/transpile
Meta: s3-q035 · mcq · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: Select ALL statements that are TRUE about transpiler optimization levels 0-3.
A.Level 0 does the minimum needed to make the circuit runnable on the target, with essentially no optimization.
B.Level 3 applies the most aggressive optimization and typically takes the longest to run.
C.A higher optimization level is guaranteed to produce fewer two-qubit gates for every circuit.
D.generate_preset_pass_manager uses optimization level 1 by default.
E.All four levels target the same basis gates and coupling constraints; they differ in how hard they work to optimize.
Answer: Correct: A, B, E
Level 0 is minimal mapping/translation with no real optimization (A). Level 3 is the most aggressive and usually the slowest (B). Every level produces a circuit valid for the SAME target constraints — the difference is optimization effort, not the constraints (E).
References
- quantum.cloud.ibm.com/docs/guides/set-optimization
- quantum.cloud.ibm.com/docs/guides/transpile-with-pass-managers
Meta: s3-q036 · multi · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: The circuit has h and t gates on qubit 0. After transpiling to a GenericBackendV2 whose basis is {cx, id, rz, sx, x, ...}, which statement about the resulting ISA circuit is TRUE?
from qiskit import QuantumCircuit
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit.providers.fake_provider import GenericBackendV2
backend = GenericBackendV2(num_qubits=5, seed=11)
qc = QuantumCircuit(2)
qc.h(0)
qc.t(0)
qc.cx(0, 1)
isa = generate_preset_pass_manager(1, backend, seed_transpiler=11).run(qc)
print(isa.count_ops())
A.It still contains a t gate, because t is a standard gate kept as-is.
B.It keeps the h gate but the t gate is removed entirely.
C.Neither h nor t survives; both are rewritten into the target basis (e.g. rz/sx).
D.Transpilation raises an error because t is not one of the basis gates.
Answer: Correct: C
The translation stage rewrites every gate into the target's basis. Since neither h nor t is a basis gate, both are decomposed into rz/sx (and the two-qubit cx stays), so the ISA circuit contains no h or t.
References
- quantum.cloud.ibm.com/docs/guides/transpiler-stages
- quantum.cloud.ibm.com/docs/guides/transpile
Meta: s3-q037 · predict-output · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: In the preset transpilation pipeline, which stage inserts SWAP gates so that every two-qubit gate acts on a physically-connected pair of qubits?
A.The layout stage.
B.The routing stage.
C.The translation stage.
D.The optimization stage.
Answer: Correct: B
Routing is the stage that makes a circuit satisfy the coupling map: when a two-qubit gate is requested between non-adjacent physical qubits, the router inserts SWAP gates to bring the qubit states together. Layout only assigns the initial virtual->physical mapping.
References
- quantum.cloud.ibm.com/docs/guides/transpiler-stages
- quantum.cloud.ibm.com/docs/guides/transpile
Meta: s3-q038 · mcq · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: This call raises. What is the reason?
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit.providers.fake_provider import GenericBackendV2
backend = GenericBackendV2(num_qubits=5, seed=42)
pm = generate_preset_pass_manager(optimization_level=4, backend=backend)
A.Valid optimization levels are 0, 1, 2, and 3; level 4 does not exist, so it raises a ValueError.
B.Level 4 exists but is only allowed for real hardware backends, not fake ones.
C.optimization_level must be passed as a string, e.g. '4'.
D.Level 4 is valid but requires seed_transpiler to be set first.
Answer: Correct: A
The preset pass managers define exactly four optimization levels: 0, 1, 2, and 3. Passing 4 is out of range and raises ValueError: Invalid optimization level 4.
References
- quantum.cloud.ibm.com/docs/guides/set-optimization
- quantum.cloud.ibm.com/docs/guides/transpile-with-pass-managers
Meta: s3-q039 · spot-bug · Difficulty 1/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: You have built pm = generate_preset_pass_manager(optimization_level=1, backend=backend). Which call actually transpiles qc into an ISA circuit using this pass manager?
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
pm = generate_preset_pass_manager(optimization_level=1, backend=backend)
# isa = ?
A.isa = pm.transpile(qc)
B.isa = pm.run(qc)
C.isa = pm(qc)
D.isa = transpile(qc, pm)
Answer: Correct: B
A pass manager executes its passes on a circuit via .run(circuit). For a preset StagedPassManager, pm.run(qc) returns the transpiled ISA circuit.
References
- quantum.cloud.ibm.com/docs/guides/transpile-with-pass-managers
- quantum.cloud.ibm.com/docs/guides/transpile
Meta: s3-q040 · mcq · Difficulty 1/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: A single Toffoli ccx(0, 1, 2) is transpiled onto a 3-qubit LINE backend (basis {cx, rz, sx, x}; connectivity 0-1-2). How many two-qubit (cx) gates does the resulting ISA circuit contain?
from qiskit import QuantumCircuit
from qiskit.transpiler import CouplingMap
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit.providers.fake_provider import GenericBackendV2
backend = GenericBackendV2(3, coupling_map=CouplingMap.from_line(3), seed=7)
qc = QuantumCircuit(3)
qc.ccx(0, 1, 2)
isa = generate_preset_pass_manager(1, backend, seed_transpiler=7).run(qc)
print(isa.count_ops().get('cx'))
A.0 — the backend runs the 3-qubit Toffoli directly.
B.Exactly 1 CX.
C.Between 2 and 5 CX.
D.6 or more CX — the Toffoli is decomposed into many one- and two-qubit basis gates, and routing on a line adds still more.
Answer: Correct: D
ccx is neither a basis gate nor a two-qubit gate, so it is decomposed. A Toffoli already needs 6 CX in an all-to-all decomposition, and routing it on a linear coupling map inserts additional CX (via SWAPs), giving well over 6 CX in practice.
References
- quantum.cloud.ibm.com/docs/guides/transpiler-stages
- quantum.cloud.ibm.com/docs/guides/transpile
Meta: s3-q041 · predict-output · Difficulty 3/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: For a StagedPassManager from generate_preset_pass_manager(...), select ALL names that are actual stages of the pipeline (they appear in pm.stages).
A.layout
B.routing
C.mitigation
D.scheduling
E.sampling
Answer: Correct: A, B, D
The preset pipeline's stages are init, layout, routing, translation, optimization, and scheduling. So layout, routing, and scheduling are real stages.
References
- quantum.cloud.ibm.com/docs/guides/transpiler-stages
- quantum.cloud.ibm.com/docs/guides/transpile-with-pass-managers
Meta: s3-q042 · multi · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: A 3-qubit circuit is transpiled with initial_layout=[2, 3, 4] onto a 5-qubit backend. What does this argument do?
from qiskit import transpile
isa = transpile(qc, backend, initial_layout=[2, 3, 4], optimization_level=0)
A.It sets the optimization level to the list [2, 3, 4].
B.It adds measurements of physical qubits 2, 3, and 4 at the end of the circuit.
C.It fixes the starting layout: virtual qubits 0, 1, 2 are placed on physical qubits 2, 3, 4 respectively.
D.It restricts the job so it runs only when physical qubits 2, 3, 4 are idle.
Answer: Correct: C
initial_layout pins the initial virtual-to-physical qubit mapping: the i-th entry is the physical qubit that virtual qubit i is assigned to. Here virtual 0->physical 2, virtual 1->physical 3, virtual 2->physical 4.
References
- quantum.cloud.ibm.com/docs/guides/transpiler-stages
- quantum.cloud.ibm.com/docs/guides/transpile
Meta: s3-q043 · mcq · Difficulty 3/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: Why must an abstract quantum circuit be transpiled before it can be run on IBM Quantum hardware through the Runtime primitives?
A.Hardware executes only ISA circuits: gates must be expressed in the device's native basis, and every two-qubit gate must act on physically-connected qubits — transpilation rewrites and routes the circuit to satisfy both.
B.Transpilation is optional; the V2 primitives silently convert any abstract circuit at submission time, so it only saves a little runtime.
C.Transpilation is needed only to draw the circuit nicely; execution accepts any circuit unchanged.
D.Transpilation exists to convert the circuit into OpenQASM 2, the only format the hardware accepts.
Answer: Correct: A
Real devices have a fixed native gate set and a limited qubit connectivity. Transpilation maps virtual qubits to physical ones, routes two-qubit gates onto connected pairs (inserting SWAPs), and translates gates into the basis set — producing an ISA circuit, which is what the V2 primitives require as input.
References
- quantum.cloud.ibm.com/docs/guides/transpile
- quantum.cloud.ibm.com/docs/guides/get-started-with-primitives
Meta: s3-q044 · mcq · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: Qubit 0 is flipped to |1⟩. The measurements deliberately map q0 -> c1 and q1 -> c0. What bitstring (order c1 c0) is observed on every shot?
from qiskit import QuantumCircuit
qc = QuantumCircuit(2, 2)
qc.x(0)
qc.measure(0, 1)   # qubit 0 -> classical bit 1
qc.measure(1, 0)   # qubit 1 -> classical bit 0
A.01
B.11
C.10
D.00
Answer: Correct: C
Qubit 0 is 1, qubit 1 is 0. The mapping stores qubit 0's result in c1 and qubit 1's result in c0, so c1=1 and c0=0. Printed as c1 c0, that is 10.
References
- quantum.cloud.ibm.com/docs/guides/measure-qubits
- quantum.cloud.ibm.com/docs/guides/construct-circuits
Meta: s3-q045 · predict-output · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: Circuit a applies X to its single qubit; circuit b applies identity to its single qubit. Which two-qubit state does a.tensor(b) prepare (bit order q1 q0)?
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
a = QuantumCircuit(1)
a.x(0)      # a's qubit -> |1>
b = QuantumCircuit(1)
b.id(0)     # b's qubit -> |0>
combined = a.tensor(b)
sv = Statevector(combined)
A.|01⟩ — b (identity) lands on the higher-order qubit and a (X) on the lower one.
B.|11⟩ — both qubits end up excited.
C.An equal superposition of all four basis states.
D.|10⟩ — a occupies the higher-order qubit, so its X sets q1 to 1 while q0 stays 0.
Answer: Correct: D
In a.tensor(b) the left operand a is placed on the MORE significant (higher-index) qubits and b on the less significant ones. So a's X acts on q1 (giving 1) and b's identity leaves q0 at 0, producing |10⟩.
References
- quantum.cloud.ibm.com/docs/guides/construct-circuits
- quantum.cloud.ibm.com/docs/api/qiskit/qiskit.circuit.QuantumCircuit
Meta: s3-q046 · predict-output · Difficulty 3/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: This code raises a CircuitError at the measure call. What is the fix?
from qiskit import QuantumCircuit
qc = QuantumCircuit(2)          # 2 qubits, 0 classical bits
qc.h(0)
qc.cx(0, 1)
qc.measure([0, 1], [0, 1])     # CircuitError
A.The circuit has no classical bits; create it as QuantumCircuit(2, 2) (or add a ClassicalRegister) so there are bits to store the outcomes.
B.measure cannot take lists of qubits/bits; you must measure each qubit in a separate call.
C.The measure method does not exist; you must call qc.measure_all() instead.
D.The qubits must be measured before the CX gate, not after it.
Answer: Correct: A
QuantumCircuit(2) creates 2 qubits and ZERO classical bits, so measure has nowhere to write. Declaring classical bits — QuantumCircuit(2, 2) or adding a ClassicalRegister — resolves it.
References
- quantum.cloud.ibm.com/docs/guides/measure-qubits
- quantum.cloud.ibm.com/docs/guides/construct-circuits
Meta: s3-q047 · spot-bug · Difficulty 1/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: What is the practical benefit of building a circuit from named registers such as QuantumRegister(3, 'data') and QuantumRegister(1, 'anc') instead of the bare QuantumCircuit(4) form?
A.Named registers make the circuit execute faster on hardware.
B.They let you address qubits and bits by meaningful groups and names (e.g. data[0], anc[0]), improving readability and letting one circuit hold several logically-distinct registers.
C.Only qubits that belong to a named register can be measured; anonymous qubits cannot.
D.Named registers are required by the transpiler; a circuit built with QuantumCircuit(4) cannot be transpiled.
Answer: Correct: B
Registers are an organizational tool. Naming them lets you reference qubits/bits by role (data, anc) and index within each group, which keeps larger circuits readable and lets one circuit contain multiple distinct registers. They carry no performance or execution requirement.
References
- quantum.cloud.ibm.com/docs/guides/construct-circuits
- quantum.cloud.ibm.com/docs/api/qiskit/qiskit.circuit.QuantumCircuit
Meta: s3-q048 · mcq · Difficulty 1/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: A 3-parameter circuit is partially bound with a dict that supplies only q. How many free parameters does partial have, and which remain?
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
p = Parameter('p'); q = Parameter('q'); r = Parameter('r')
qc = QuantumCircuit(1)
qc.rx(p, 0)
qc.ry(q, 0)
qc.rz(r, 0)
partial = qc.assign_parameters({q: 1.0})
A.0 — assigning any dict binds all of the circuit's parameters at once.
B.1 — only q remains free.
C.2 — p and r remain free; only q was bound.
D.It raises, because a dict must supply a value for every parameter.
Answer: Correct: C
A dict binds exactly the parameters it names. Passing {q: 1.0} binds only q, leaving p and r free — so partial.num_parameters is 2. This is partial binding.
References
- quantum.cloud.ibm.com/docs/guides/construct-circuits
- quantum.cloud.ibm.com/docs/api/qiskit/qiskit.circuit.Parameter
Meta: s3-q049 · predict-output · Difficulty 1/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: Select ALL true statements about parameterized circuits and how they interact with binding and transpilation.
A.The values in a LIST passed to assign_parameters are matched to qc.parameters in alphabetical name order, not in gate-insertion order.
B.A parameterized circuit can be transpiled first and have its parameters assigned afterward; the ISA circuit keeps the parameters until you bind them.
C.assign_parameters must be called before transpilation, otherwise the parameters are lost.
D.A dict passed to assign_parameters may bind only a subset of parameters (partial binding).
E.Reusing the same Parameter object on two gates raises an error.
Answer: Correct: A, B, D
List binding follows qc.parameters, which is sorted alphabetically by name (A). Parameters survive transpilation, so you can transpile once and bind many times afterward (B). A dict binds only the named parameters (D).
References
- quantum.cloud.ibm.com/docs/guides/construct-circuits
- quantum.cloud.ibm.com/docs/api/qiskit/qiskit.circuit.Parameter
Meta: s3-q050 · multi · Difficulty 3/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: The SAME parameter th is used on two different gates. How many free parameters does qc have, and what happens when th is bound?
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
th = Parameter('th')
qc = QuantumCircuit(2)
qc.rx(th, 0)
qc.rx(th, 1)
bound = qc.assign_parameters({th: 0.5})
A.qc has 2 free parameters — each gate gets its own independent copy of th.
B.qc has 1 free parameter, but binding sets only the first rx; the second stays symbolic.
C.It raises, because one Parameter object cannot be reused across two gates.
D.qc has 1 free parameter; binding th sets BOTH rx gates to 0.5 at once.
Answer: Correct: D
A Parameter is a single symbolic object. Reusing th on both gates means qc.num_parameters is 1, and assigning th substitutes that one value into every gate that references it — so both rx gates become 0.5. This is how weight-sharing ansätze tie gates together.
References
- quantum.cloud.ibm.com/docs/guides/construct-circuits
- quantum.cloud.ibm.com/docs/api/qiskit/qiskit.circuit.Parameter
Meta: s3-q051 · predict-output · Difficulty 3/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: Qubit 0 is set to |1⟩ and measured into c0. A switch on c0 applies X to qubit 1 in case(0) and identity in the DEFAULT case. Qubit 1 is then measured. What outcome (order c1 c0) appears on every shot?
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
qr = QuantumRegister(2, 'q')
cr = ClassicalRegister(2, 'c')
qc = QuantumCircuit(qr, cr)
qc.x(0)
qc.measure(0, 0)
with qc.switch(cr[0]) as case:
    with case(0):
        qc.x(1)
    with case(case.DEFAULT):
        qc.id(1)
qc.measure(1, 1)
A.01 on every shot — c0=1 takes the DEFAULT branch (identity), so qubit 1 stays 0.
B.11 on every shot — the case(0) branch runs and applies X to qubit 1.
C.10 on every shot.
D.A mix of 00 and 11, roughly 50/50.
Answer: Correct: A
c0 is deterministically 1 (qubit 0 was flipped). The switch matches value 1 against case(0) (no match) and falls to case(DEFAULT), which applies identity, leaving qubit 1 at 0. So c1=0, c0=1 → 01 every shot.
References
- quantum.cloud.ibm.com/docs/guides/classical-feedforward-and-control-flow
- quantum.cloud.ibm.com/docs/api/qiskit/qiskit.circuit.QuantumCircuit
Meta: s3-q052 · predict-output · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: Both qubits 0 and 1 are set to |1⟩ and measured into the 2-bit register c. An if_test guarded by expr.equal(c, 3) flips qubit 2, which is read into register o. What value does o hold?
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.circuit.classical import expr
qr = QuantumRegister(3, 'q')
c = ClassicalRegister(2, 'c')
o = ClassicalRegister(1, 'o')
qc = QuantumCircuit(qr, c, o)
qc.x(0); qc.x(1)
qc.measure(0, 0); qc.measure(1, 1)
with qc.if_test(expr.equal(c, 3)):
    qc.x(2)
qc.measure(2, o[0])
A.o = 0 — expr.equal compares individual bits, so it can never match the whole-register value 3.
B.o = 1 — c holds binary 11 = 3, so the condition is true and qubit 2 is flipped.
C.It raises — an if_test condition must be a (register, value) tuple; an expr is not accepted.
D.o is random 0 or 1 because qubit 2 was never given a definite initial state.
Answer: Correct: B
expr.equal(c, 3) builds a classical expression that is true when the register c, interpreted as an integer, equals 3. With both bits set, c = binary 11 = 3, so the condition holds and X is applied to qubit 2, making o = 1.
References
- quantum.cloud.ibm.com/docs/guides/classical-feedforward-and-control-flow
- quantum.cloud.ibm.com/docs/api/qiskit/circuit_classical
Meta: s3-q053 · mcq · Difficulty 3/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.