Skip to content
Kartikey Purohit
← Course overview

Day 1 — Circuit Basics

Question Bank

20 questions. Multiple choice A–D unless marked "select all that apply". Assume Qiskit 2.5.1 and standard imports:

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.quantum_info import Statevector, Operator
from qiskit.primitives import StatevectorSampler

Answers are in solution-bank.md — no peeking until you've committed to an answer.


Q1. What does this print?

qc = QuantumCircuit(3, 2)
print(qc.num_qubits, qc.num_clbits, qc.width())
  • A. 3 2 3
  • B. 3 2 5
  • C. 2 3 5
  • D. 3 2 6

Q2. Which snippet builds this circuit?

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

Q3. What does this print?

qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()
print(qc.count_ops())
  • A. OrderedDict({'measure': 2, 'h': 1, 'cx': 1})
  • B. OrderedDict({'h': 1, 'cx': 1})
  • C. OrderedDict({'measure': 2, 'h': 1, 'cx': 1, 'barrier': 1})
  • D. It raises an error because the circuit has no classical register.

Q4. What is the depth of this circuit?

qc = QuantumCircuit(3)
qc.h(range(3))
qc.cx(0, 1)
qc.cx(1, 2)
  • A. 2
  • B. 3
  • C. 5
  • D. 4

Q5. What are the counts?

qc = QuantumCircuit(2, 2)
qc.x(0)
qc.measure([0, 1], [0, 1])
sampler = StatevectorSampler(seed=42)
print(sampler.run([qc], shots=100).result()[0].data.c.get_counts())
  • A. {'10': 100}
  • B. {'01': 100}
  • C. {'01': 50, '10': 50}
  • D. {'1': 100}

Q6. What does this print?

qc = QuantumCircuit(2, 2)
qc.h(0)
qc.measure_all()
print(qc.num_clbits, [r.name for r in qc.cregs])
  • A. 2 ['c']
  • B. 2 ['meas']
  • C. 4 ['c', 'meas']
  • D. 4 ['meas', 'c']

Q7. (Select all that apply.) Which of the following exist as QuantumCircuit methods in Qiskit 2.x?

  • A. qc.cnot(0, 1)
  • B. qc.id(0)
  • C. qc.i(0)
  • D. qc.toffoli(0, 1, 2)

Q8. What does this print?

qc = QuantumCircuit(1)
qc.s(0)
qc.t(0)
inv = qc.inverse()
print([ci.operation.name for ci in inv.data])
  • A. ['sdg', 'tdg']
  • B. ['tdg', 'sdg']
  • C. ['s', 't']
  • D. ['t', 's']

Q9. What does this print?

a = QuantumCircuit(2)
a.h(0)
b = QuantumCircuit(2)
b.cx(0, 1)
c = a.compose(b)
print(len(a.data), len(c.data))
  • A. 2 2
  • B. 1 2
  • C. 1 1
  • D. 2 1

Q10. What happens here?

qc = QuantumCircuit(1, 1)
qc.h(0)
qc.measure(0, 0)
g = qc.to_gate()
  • A. g is a 1-qubit Gate containing the measurement.
  • B. It raises QiskitError because a circuit with classical bits cannot become a Gate.
  • C. It silently drops the measurement and returns a Gate with just the h.
  • D. It returns an Instruction instead of a Gate.

Q11. What does this print?

x1 = QuantumCircuit(1); x1.x(0)
h1 = QuantumCircuit(1); h1.h(0)
t = x1.tensor(h1)
print(Statevector(t).probabilities_dict())
  • A. {'01': 0.5, '11': 0.5}
  • B. {'10': 0.5, '11': 0.5}
  • C. {'00': 0.5, '01': 0.5}
  • D. {'10': 0.5, '01': 0.5}

Q12. What does this print?

from qiskit.circuit.library import XGate
g = XGate().control(2)
print(g.name, g.num_qubits)
  • A. mcx 3
  • B. ccx 2
  • C. cx 3
  • D. ccx 3

Q13. What does this print?

qc = QuantumCircuit(2)
qc.h(0)
qc.barrier()
qc.x(1)
print(qc.depth(), qc.size())
  • A. 1 2
  • B. 2 3
  • C. 2 2
  • D. 3 3

Q14. Both circuits prepare a 4-qubit GHZ state. What are their depths, in order (chain, tree)?

chain = QuantumCircuit(4)
chain.h(0); chain.cx(0, 1); chain.cx(1, 2); chain.cx(2, 3)
 
tree = QuantumCircuit(4)
tree.h(0); tree.cx(0, 1); tree.cx(0, 2); tree.cx(1, 3)
  • A. 4 and 4
  • B. 4 and 3
  • C. 3 and 3
  • D. 4 and 2

Q15. (Select all that apply.) Which statements are TRUE (verified with Operator)?

  • A. Two t gates in a row are equivalent to one s gate.
  • B. Two sx gates in a row are equivalent to one x gate.
  • C. rz(pi) is exactly equal (including global phase) to z.
  • D. swap(0, 1) is equivalent to cx(0,1); cx(1,0); cx(0,1).

Q16. What does this print?

qc = QuantumCircuit(3)
qc.h(0)
qc.cx(0, 1)
qc.measure_active()
print(qc.cregs)
  • A. [ClassicalRegister(3, 'meas')]
  • B. [ClassicalRegister(2, 'meas')]
  • C. [ClassicalRegister(2, 'c')]
  • D. []measure_active needs an existing classical register.

Q17. What does this print?

qc = QuantumCircuit(1)
alias = qc
cp = qc.copy()
qc.h(0)
print(alias.size(), cp.size())
  • A. 0 0
  • B. 1 1
  • C. 0 1
  • D. 1 0

Q18. What does this print?

a = QuantumCircuit(1)
a.x(0)
b = QuantumCircuit(1)
b.h(0)
c = a.compose(b, front=True)
print([ci.operation.name for ci in c.data])
  • A. ['x', 'h']
  • B. ['h', 'x']
  • C. ['x']front=True replaces the circuit body.
  • D. It raises an error; compose has no front argument.

Q19. (Select all that apply.) For which gates does swapping the two qubit arguments leave the operator unchanged (i.e., gate(0,1) == gate(1,0) as an Operator)?

  • A. cz
  • B. cx
  • C. swap
  • D. ecr

Q20. What does this print?

ghz = QuantumCircuit(3)
ghz.h(0); ghz.cx(0, 1); ghz.cx(1, 2)
ghz.measure_all()
sampler = StatevectorSampler(seed=7)
counts = sampler.run([ghz], shots=1000).result()[0].data.meas.get_counts()
print(sorted(counts.keys()))
  • A. ['000', '111']
  • B. ['000', '001', '110', '111']
  • C. ['111']
  • D. ['000', '011', '100', '111']