1
$\begingroup$

Is it possible to run qasm files on jupyter notebook (like with the qasm_simulator)? I downloaded one code file and I would like to play around with it on jupyter notebook.

$\endgroup$
1

1 Answer 1

3
$\begingroup$

You can use QuantumCircuit.from_qasm_str() like this:

from qiskit import QuantumCircuit

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

circ = QuantumCircuit.from_qasm_str(qasm_str)
circ.draw('mpl')
$\endgroup$
1
  • $\begingroup$ Thank you very much $\endgroup$
    – Berni89
    Nov 11, 2021 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.