Title: CertiQ — C1000-179 / 8 · Operate with OpenQASM

Question: You export a small circuit to OpenQASM 3 with qiskit.qasm3.dumps(qc). Which string is returned exactly?
from qiskit import QuantumCircuit
from qiskit import qasm3
qc = QuantumCircuit(1, 1)
qc.h(0)
qc.measure(0, 0)
print(qasm3.dumps(qc))
A.`` OPENQASM 3.0; include "stdgates.inc"; bit[1] c; qubit[1] q; h q[0]; c[0] = measure q[0]; ``
B.`` OPENQASM 3.0; include "stdgates.inc"; creg c[1]; qreg q[1]; h q[0]; c[0] = measure q[0]; ``
C.`` OPENQASM 3.0; include "stdgates.inc"; bit[1] c; qubit[1] q; h q[0]; measure q[0] -> c[0]; ``
D.`` OPENQASM 3.0; include "qelib1.inc"; bit[1] c; qubit[1] q; h q[0]; c[0] = measure q[0]; ``
Answer: Correct: A
OpenQASM 3 declares classical and quantum data with the bit[n]/qubit[n] keywords (not creg/qreg), pulls its standard gates from stdgates.inc, and writes measurement as an assignment c[0] = measure q[0];. Qiskit's exporter lists the classical bit declaration before the qubit declaration, exactly matching option A.
References
- quantum.cloud.ibm.com/docs/guides/interoperate-qiskit-qasm3
- quantum.cloud.ibm.com/docs/api/qiskit/qasm3
Meta: s8-q010 · predict-output · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: You have an open, writable text file object f and want to write the OpenQASM 3 representation of qc into that file. Which call does this correctly?
from qiskit import qasm3
# f is an open text file object, e.g. f = open("circuit.qasm", "w")
# qc is a QuantumCircuit
...  # which call?
A.qasm3.dump(qc, f)
B.qasm3.dumps(qc, f)
C.f.write(qasm3.dump(qc))
D.qasm3.dump(f, qc)
Answer: Correct: A
qasm3.dump(circuit, stream) serializes the circuit and writes it to the given file-like object, returning None. The circuit comes first, the stream second.
References
- quantum.cloud.ibm.com/docs/guides/interoperate-qiskit-qasm3
- quantum.cloud.ibm.com/docs/api/qiskit/qasm3
Meta: s8-q011 · mcq · Difficulty 1/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: The variable program holds a complete OpenQASM 2 program as a Python string. Which call parses it into a QuantumCircuit?
from qiskit import qasm2
program = '''OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
creg c[2];
h q[0];
cx q[0], q[1];
measure q -> c;
'''
circuit = ...  # which call?
A.circuit = qasm2.loads(program)
B.circuit = qasm2.load(program)
C.circuit = qasm2.parse(program)
D.circuit = qasm2.dumps(program)
Answer: Correct: A
qasm2.loads (string-'s') parses an OpenQASM 2 program supplied as a string and returns a QuantumCircuit. Its file-based counterpart is qasm2.load, which takes a filename.
References
- quantum.cloud.ibm.com/docs/guides/interoperate-qiskit-qasm2
- quantum.cloud.ibm.com/docs/api/qiskit/qasm2
Meta: s8-q012 · mcq · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: This code builds a circuit with an if_test block and tries to export it to OpenQASM 2, but the export raises an error. Which single change makes the export succeed while representing the same conditional circuit?
from qiskit import QuantumCircuit, qasm2
qc = QuantumCircuit(1, 1)
qc.h(0)
qc.measure(0, 0)
with qc.if_test((qc.clbits[0], 1)):
    qc.x(0)
text = qasm2.dumps(qc)  # raises QASM2ExportError
A.Export with qasm3.dumps(qc) instead.
B.Keep OpenQASM 2 but relax the parser: qasm2.dumps(qc, strict=False).
C.Flatten the circuit first: qasm2.dumps(qc.decompose()).
D.Use the circuit's string form directly: str(qc).
Answer: Correct: A
Structured control flow such as if_test is an OpenQASM 3 feature. OpenQASM 2 has no general if construct (only register-equality conditions), so the v2 exporter raises QASM2ExportError. Exporting with qasm3.dumps succeeds and emits an if (...) { ... } block.
References
- quantum.cloud.ibm.com/docs/guides/qasm-feature-table
- quantum.cloud.ibm.com/docs/guides/interoperate-qiskit-qasm3
Meta: s8-q013 · spot-bug · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: The circuit below is exported with qiskit.qasm3.dumps(qc). Which line appears in the emitted program to record the measurement of qubit 0 into classical bit 0?
from qiskit import QuantumCircuit
from qiskit import qasm3
qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.measure(0, 0)
qc.measure(1, 1)
print(qasm3.dumps(qc))
A.c[0] = measure q[0];
B.measure q[0] -> c[0];
C.c[0] = measure(q[0]);
D.measure q[0], c[0];
Answer: Correct: A
In OpenQASM 3, measure is an expression whose result is assigned to a classical bit: c[0] = measure q[0];. This assignment form replaces the OpenQASM 2 arrow syntax.
References
- quantum.cloud.ibm.com/docs/guides/interoperate-qiskit-qasm3
- quantum.cloud.ibm.com/docs/api/qiskit/qasm3
Meta: s8-q014 · predict-output · Difficulty 1/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: A file begins with the line OPENQASM 3.0; and uses qubit/bit declarations. A teammate tries to load it with qiskit.qasm2.loads(program). What is the result?
from qiskit import qasm2
# program starts with 'OPENQASM 3.0;' and declares qubit[2] q; bit[2] c; ...
circuit = qasm2.loads(program)
A.It raises QASM2ParseError: qasm2.loads handles only OpenQASM 2.0, and the version statement declares 3.0.
B.It loads successfully; the version statement is ignored and the rest is parsed as OpenQASM 2.
C.It loads, silently downgrading the OpenQASM 3 features to their OpenQASM 2 equivalents.
D.It raises ModuleNotFoundError because stdgates.inc cannot be located.
Answer: Correct: A
The OpenQASM 2 parser checks the version statement and accepts only OPENQASM 2.0. A 3.0 header makes qasm2.loads raise QASM2ParseError ('can only handle OpenQASM 2.0, but given 3.0'). The two language versions have separate importers: use qiskit.qasm3.loads for OpenQASM 3.
References
- quantum.cloud.ibm.com/docs/guides/interoperate-qiskit-qasm2
- quantum.cloud.ibm.com/docs/api/qiskit/qasm2
Meta: s8-q015 · mcq · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: A QuantumCircuit with 2 qubits and 3 classical bits is exported with qiskit.qasm3.dumps. Which pair of declaration lines does the OpenQASM 3 output contain?
from qiskit import QuantumCircuit
from qiskit import qasm3
qc = QuantumCircuit(2, 3)  # 2 qubits, 3 clbits
qc.h(0)
print(qasm3.dumps(qc))
A.bit[3] c; and qubit[2] q;
B.bit[2] c; and qubit[3] q;
C.creg c[3]; and qreg q[2];
D.bit c[3]; and qubit q[2];
Answer: Correct: A
OpenQASM 3 sizes a register by putting the width in brackets right after the type name: bit[3] c; for the 3-bit ClassicalRegister and qubit[2] q; for the 2-qubit QuantumRegister.
References
- quantum.cloud.ibm.com/docs/guides/interoperate-qiskit-qasm3
- quantum.cloud.ibm.com/docs/guides/qasm-feature-table
Meta: s8-q016 · predict-output · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: A single-qubit circuit has a non-zero global phase (qc.global_phase = pi/2) and one h gate. You round-trip it through OpenQASM 2 with qc2 = qasm2.loads(qasm2.dumps(qc)). Which statement about qc2 is correct?
import math
from qiskit import QuantumCircuit, qasm2
qc = QuantumCircuit(1)
qc.global_phase = math.pi / 2
qc.h(0)
qc2 = qasm2.loads(qasm2.dumps(qc))
A.The gate sequence is preserved, but the global phase is dropped (qc2.global_phase == 0), so qc2 != qc.
B.qc2 is exactly equal to qc, global phase included.
C.qasm2.dumps(qc) raises, because a non-zero global phase cannot be exported to OpenQASM 2.
D.The global phase survives, but the h gate is lost in the round-trip.
Answer: Correct: A
OpenQASM 2 has no way to represent a circuit-level global phase, so the exporter simply omits it (it does not error). Re-importing gives a circuit whose gates match but whose global_phase is 0, hence qc2 != qc. Global phase (gphase) is an OpenQASM 3 concept.
References
- quantum.cloud.ibm.com/docs/guides/qasm-feature-table
- quantum.cloud.ibm.com/docs/guides/interoperate-qiskit-qasm2
Meta: s8-q017 · mcq · Difficulty 3/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: The same circuit is exported both ways: s2 = qasm2.dumps(qc) and s3 = qasm3.dumps(qc). Which statement about the include directive in each output is correct?
from qiskit import qasm2, qasm3
s2 = qasm2.dumps(qc)
s3 = qasm3.dumps(qc)
A.s2 includes "qelib1.inc"; s3 includes "stdgates.inc".
B.Both s2 and s3 include "qelib1.inc".
C.Both s2 and s3 include "stdgates.inc".
D.s2 includes "stdgates.inc"; s3 includes "qelib1.inc".
Answer: Correct: A
Each OpenQASM version ships its own standard-gate include file. OpenQASM 2 output references qelib1.inc (the library from the original OpenQASM 2 paper), while OpenQASM 3 output references stdgates.inc.
References
- quantum.cloud.ibm.com/docs/guides/interoperate-qiskit-qasm2
- quantum.cloud.ibm.com/docs/guides/interoperate-qiskit-qasm3
Meta: s8-q018 · mcq · Difficulty 1/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: A circuit contains a user-defined gate mygate (built from a named sub-circuit and appended with to_gate()). When you call qiskit.qasm3.dumps(qc), how is mygate represented in the output?
from qiskit import QuantumCircuit
from qiskit import qasm3
sub = QuantumCircuit(1, name="mygate")
sub.rz(0.5, 0)
sub.h(0)
qc = QuantumCircuit(1)
qc.append(sub.to_gate(), [0])
print(qasm3.dumps(qc))
A.A gate mygate ... { ... } definition is emitted, and the circuit body then invokes mygate q[0];.
B.The gate is inlined as its constituent rz/h operations, with no gate definition.
C.The export raises an error, because only gates from stdgates.inc can be exported.
D.mygate is treated as a standard gate from stdgates.inc, so no definition is written.
Answer: Correct: A
OpenQASM 3 supports user gate definitions, and Qiskit's exporter writes a gate mygate ... { ... } block for the custom instruction and then calls it by name in the body. The definition preserves the sub-circuit structure rather than flattening it.
References
- quantum.cloud.ibm.com/docs/guides/qasm-feature-table
- quantum.cloud.ibm.com/docs/api/qiskit/qasm3
Meta: s8-q019 · mcq · Difficulty 3/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: A circuit uses an unbound Parameter named theta and is exported with qiskit.qasm3.dumps. Which declaration line does the OpenQASM 3 output contain for theta?
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
from qiskit import qasm3
theta = Parameter("theta")
qc = QuantumCircuit(1)
qc.rx(theta, 0)
print(qasm3.dumps(qc))
A.input float[64] theta;
B.float[64] theta;
C.input angle theta;
D.parameter theta;
Answer: Correct: A
Qiskit's OpenQASM 3 exporter represents an unbound Parameter as a program input of type float[64], emitting input float[64] theta;. input marks a value supplied at run time, and float[64] is a classical scalar type.
References
- quantum.cloud.ibm.com/docs/guides/qasm-feature-table
- quantum.cloud.ibm.com/docs/api/qiskit/qasm3
Meta: s8-q020 · predict-output · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: In OpenQASM 3, how do the declarations bit[4] c; and int[4] n; differ, and how does Qiskit's OpenQASM 3 importer (qiskit.qasm3.loads) handle each?
A.bit[4] is a register of four classical bits (imported as a ClassicalRegister); int[4] is a single 4-bit signed integer, which the Qiskit importer does not currently support parsing.
B.Both declare 4-bit signed integers and are interchangeable; the importer maps each to a Python int.
C.bit[4] is a 4-bit signed integer and int[4] is a register of four bits; the importer treats them the other way around.
D.Both are imported as ClassicalRegister objects of length 4.
Answer: Correct: A
bit is the classical-bit type: bit[4] is an array of four bits, which Qiskit represents as a ClassicalRegister (and bit as a single Clbit). int[n] is a distinct scalar type -- an n-bit signed integer. Qiskit's OpenQASM 3 importer supports bit/bit[n] register declarations but does not currently parse int variable declarations (feature table: int is unsupported for import).
References
- quantum.cloud.ibm.com/docs/guides/qasm-feature-table
- quantum.cloud.ibm.com/docs/guides/interoperate-qiskit-qasm3
Meta: s8-q021 · mcq · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: You rely on Qiskit's OpenQASM 3 importer (qiskit.qasm3.loads, via the qiskit-qasm3-import extension) to parse programs that declare classical data. Based on the OpenQASM 3 feature support in the Qiskit SDK, select the TWO statements that are correct.
A.A bit[n] declaration is supported and is imported as a ClassicalRegister.
B.An int[n] declaration is parsed into a native Python integer variable.
C.A complex declaration is not supported: the Qiskit SDK cannot represent or parse it.
D.An angle declaration is parsed into a Qiskit Parameter object.
E.Every OpenQASM 3 scalar type, including duration and stretch, can be parsed by the importer.
Answer: Correct: A, C
Per the OpenQASM 3 feature table, bit/bit[n] is fully supported and maps to Clbit/ClassicalRegister, while complex is unsupported in the Qiskit SDK (it can be neither parsed nor represented). Those are the two accurate statements.
References
- quantum.cloud.ibm.com/docs/guides/qasm-feature-table
- quantum.cloud.ibm.com/docs/guides/interoperate-qiskit-qasm3
Meta: s8-q022 · multi · Difficulty 3/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: You are calling the Qiskit Runtime REST API directly (for example, with curl). How must your credential be supplied on each request?
A.In an HTTP header Authorization: Bearer <TOKEN>, where <TOKEN> is an IBM Cloud IAM access (bearer) token.
B.In an X-API-Key: <API_KEY> header containing your raw IBM Cloud API key.
C.With HTTP Basic authentication: Authorization: Basic <base64(username:password)>.
D.As a URL query parameter, e.g. ...?apikey=<API_KEY>.
Answer: Correct: A
Every Qiskit Runtime REST API call must carry an IBM Cloud Identity and Access Management (IAM) bearer token in the Authorization: Bearer <TOKEN> header (alongside a Service-CRN header identifying the instance and an IBM-API-Version header). The bearer token is obtained by exchanging your API key at the IAM token endpoint.
References
- quantum.cloud.ibm.com/docs/api/qiskit-runtime-rest
- quantum.cloud.ibm.com/docs/guides/cloud-setup-rest-api
Meta: s8-q023 · mcq · Difficulty 1/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: Using the Qiskit Runtime REST API, how do you submit a Sampler primitive job to run a circuit?
A.Send an HTTP POST to the /api/v1/jobs endpoint with a JSON body whose program_id is "sampler".
B.Send an HTTP GET to /api/v1/jobs?primitive=SamplerV2.
C.Send an HTTP POST to a dedicated /api/v1/sampler endpoint.
D.Send an HTTP POST to /api/v1/jobs with program_id set to the class name "SamplerV2".
Answer: Correct: A
Primitive jobs are created with a POST to the /api/v1/jobs endpoint. The primitive is selected by the program_id field in the JSON body, whose valid values are the lowercase strings "sampler" and "estimator". The circuits are passed as OpenQASM 3 strings inside params.pubs.
References
- quantum.cloud.ibm.com/docs/api/qiskit-runtime-rest
- quantum.cloud.ibm.com/docs/guides/primitives-rest-api
Meta: s8-q024 · mcq · Difficulty 1/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.

Question: You are authenticating to the Qiskit Runtime REST API. Regarding the IBM Cloud IAM bearer token used in the Authorization header, select the TWO correct statements.
A.You obtain the token by sending a POST to the IAM token endpoint (https://iam.cloud.ibm.com/identity/token) with grant_type=urn:ibm:params:oauth:grant-type:apikey and your API key.
B.The bearer token is simply your permanent IBM Cloud API key, sent verbatim.
C.The token is temporary (it expires, for example after about one hour); once it expires you must request a new one.
D.The token never expires and can be reused indefinitely across sessions.
E.The token is returned to you in the response body of your first POST /api/v1/jobs call.
Answer: Correct: A, C
The bearer token is minted by exchanging your API key at the IAM token endpoint (a POST with the apikey grant type), and it is short-lived -- the response's expires_in is on the order of an hour, after which you must obtain a fresh token. These are the two correct statements.
References
- quantum.cloud.ibm.com/docs/api/qiskit-runtime-rest
- quantum.cloud.ibm.com/docs/guides/cloud-setup-rest-api
Meta: s8-q025 · multi · Difficulty 2/3
AI-generated, execution-verified — CertiQ. Unofficial: not affiliated with, endorsed by, or sponsored by IBM.