Skip to content
Kartikey Purohit
← Course overview

Day 7 — Visualization & QASM

Question Bank

20 multiple-choice questions. Pick ONE answer each. All circuit diagrams are real draw('text') outputs from qiskit 2.5.1. Answers and explanations in solution-bank.md.


Q1. In Qiskit 2.x, what does qc.draw() return when called with no arguments?

  • A. A matplotlib.figure.Figure rendered with the default stylesheet
  • B. A TextDrawing object that displays the circuit as ASCII art
  • C. A raw LaTeX source string
  • D. None — it prints the circuit directly to stdout

Q2. A student runs qc.draw('mpl', reverse_bits=True) and then executes qc with a Sampler. Compared to running the same circuit drawn without reverse_bits, the measured counts will be:

  • A. Identical — reverse_bits changes only how the diagram is displayed
  • B. Bit-reversed — every '01' becomes '10'
  • C. Different only if the circuit contains multi-qubit gates
  • D. Identical only if the circuit is symmetric under qubit exchange

Q3. What does qc.draw('text', fold=-1) do?

  • A. Raises a ValueErrorfold must be positive
  • B. Folds the diagram after every single layer
  • C. Disables folding so the whole circuit is drawn in one row, however wide
  • D. Reverses the drawing so time flows right → left

Q4. qc has 5 qubits but gates on only two of them. After qc.draw('text', idle_wires=False), which statement is true?

  • A. The drawing shows 2 wires, and qc.num_qubits is now 2
  • B. The drawing shows 2 wires, and qc.num_qubits is still 5
  • C. The idle qubits are removed from the circuit and released back to the backend
  • D. The drawing shows 5 wires but grays out the idle ones

Q5. This circuit is run with 1000 shots on an ideal simulator:

     ┌───┐     ┌─┐
q_0: ┤ H ├──■──┤M├───
     └───┘┌─┴─┐└╥┘┌─┐
q_1: ─────┤ X ├─╫─┤M├
          └───┘ ║ └╥┘
c: 2/═══════════╩══╩═
                0  1

Which counts dictionary is most plausible?

  • A. {'00': 493, '11': 507}
  • B. {'01': 493, '10': 507}
  • C. {'00': 250, '01': 250, '10': 250, '11': 250}
  • D. {'11': 1000}

Q6. Which single statement produces this drawing?

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

Q7. Which gate sequence produces this drawing?

q_0: ─X──────■──
      │      │
q_1: ─X──■───■──
         │ ┌─┴─┐
q_2: ────■─┤ X ├
           └───┘
  • A. qc.cx(0, 1); qc.cz(1, 2); qc.ccx(0, 1, 2)
  • B. qc.swap(0, 1); qc.cz(1, 2); qc.ccx(0, 1, 2)
  • C. qc.swap(0, 1); qc.cx(1, 2); qc.cz(0, 2)
  • D. qc.ccx(0, 1, 2); qc.cz(1, 2); qc.swap(0, 1)

Q8. This 3-qubit circuit is run with many shots on an ideal simulator:

     ┌───┐     ┌─┐
q_0: ┤ H ├──■──┤M├───
     └───┘  │  └╥┘
q_1: ───────┼───╫────
          ┌─┴─┐ ║ ┌─┐
q_2: ─────┤ X ├─╫─┤M├
          └───┘ ║ └╥┘
c: 3/═══════════╩══╩═
                0  2

Which two bitstring keys appear in the counts?

  • A. '00' and '11'
  • B. '000' and '011'
  • C. '000' and '101'
  • D. '000' and '110'

Q9. plot_histogram({'00': 40, '01': 30, '10': 20, '11': 10}, number_to_keep=2) produces a chart whose x-axis labels are:

  • A. '00', '01' — the other outcomes are silently dropped
  • B. '00', '01', 'rest' — the two largest bars plus one aggregated bar
  • C. '10', '11', 'rest' — the two smallest bars plus one aggregated bar
  • D. '00', '01', '10', '11'number_to_keep only affects colors

Q10. Why does Qiskit provide plot_distribution in addition to plot_histogram?

  • A. plot_distribution renders in 3D
  • B. plot_distribution displays (quasi-)probabilities, which can be negative after mitigation — raw shot counts never can
  • C. plot_histogram cannot show more than one dataset
  • D. plot_distribution is required for circuits with more than 10 qubits

Q11. You call plot_bloch_multivector on the state produced by h(0); cx(0, 1). What appears?

  • A. Two spheres: q0's arrow on +X, q1's arrow on +Z
  • B. Two spheres: both arrows pointing to +Z
  • C. Two spheres: both arrows have zero length (tips at the sphere centers)
  • D. One sphere with two arrows at antipodal points

Q12. On a plot_state_qsphere plot, the size and color of each blob encode, respectively:

  • A. Size = phase, color = probability
  • B. Size = probability (amplitude magnitude), color = relative phase
  • C. Size = qubit index, color = basis state
  • D. Size = entanglement entropy, color = purity

Q13. Starting from |0⟩, you apply h and then sdg. Where does the Bloch vector point?

  • A. +Y
  • B. −Y
  • C. +X
  • D. −Z

Q14. For the state produced by h(0); cx(0, 1), Statevector.draw('latex_source') returns:

  • A. \frac{\sqrt{2}}{2} |00\rangle+\frac{\sqrt{2}}{2} |11\rangle
  • B. \frac{1}{2} |00\rangle+\frac{1}{2} |11\rangle
  • C. \frac{\sqrt{2}}{2} |01\rangle+\frac{\sqrt{2}}{2} |10\rangle
  • D. |00\rangle+|11\rangle

Q15. Consider this OpenQASM 3 program:

OPENQASM 3.0;
include "stdgates.inc";
qubit[2] q;
bit[2] c;
x q[0];
h q[1];
cx q[1], q[0];
c = measure q;

Which Qiskit snippet builds the same circuit?

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

Q16. What state does this program prepare (before any measurement)?

OPENQASM 3.0;
include "stdgates.inc";
qubit[3] q;
h q[0];
cx q[0], q[1];
cx q[1], q[2];
  • A. (|000⟩ + |111⟩)/√2
  • B. (|000⟩ + |001⟩)/√2
  • C. (|001⟩ + |110⟩)/√2
  • D. |+⟩|+⟩|+⟩

Q17. This OpenQASM 2 program is run with 1000 shots on an ideal simulator:

OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
creg c[2];
h q[0];
cx q[0],q[1];
x q[1];
measure q -> c;

Which counts are expected?

  • A. Roughly 500 × '00' and 500 × '11'
  • B. Roughly 500 × '01' and 500 × '10'
  • C. 1000 × '01'
  • D. Roughly 500 × '00' and 500 × '10'

Q18. This OpenQASM 3 program is run with many shots (ideal, with mid-circuit measurement support):

OPENQASM 3.0;
include "stdgates.inc";
qubit[2] q;
bit[2] c;
h q[0];
c[0] = measure q[0];
if (c[0]) {
  x q[1];
}
c[1] = measure q[1];

Which outcome pattern results?

  • A. Only '00' and '11', ~50% each — bit c1 always equals bit c0
  • B. Only '01' and '10', ~50% each — bit c1 is always the opposite of c0
  • C. All four bitstrings, ~25% each
  • D. The program is invalid — OpenQASM 3 has no if statement

Q19. Which line correctly writes circuit qc as an OpenQASM 3 file at bell.qasm?

  • A. qasm3.dump(qc, "bell.qasm")
  • B. qasm3.dumps(qc, "bell.qasm")
  • C. with open("bell.qasm", "w") as f: qasm3.dump(qc, f)
  • D. qasm3.load(qc, "bell.qasm")

Q20. Which feature list is available in OpenQASM 3 but NOT in OpenQASM 2?

  • A. qreg/creg declarations and the qelib1.inc include
  • B. Block-structured if/else/for/while, input runtime parameters, and typed classical data (int, float, bool)
  • C. The cx gate and register-indexed gate operands
  • D. Measurement of a whole quantum register in one statement