Notepad/enter/Machine Tips (Quantum)/Project Vault/Quantum Master's Paper/Code Samples/templates/Exercise 1.md

1.2 KiB

Exercise 1 - Here is a general outline of qisket circuit template. Transpiled the quantum circuit on the IBM-Q backend and draws the optimized circuit. This is a great first step to visualize what's going on. Custom code is what you input in the commented area and I give you samples for that in the next section.

import qiskit

# Qiskit quantum circuits libraries

quantum_circuit = qiskit.circuit.library.QuantumVolume(5)

quantum_circuit.measure_all()

quantum_circuit.draw()

# prepare your circuit to run

from qiskit import IBMQ

# Get the API token in

# https://quantum-computing.ibm.com/

IBMQ.save_account("YOUR TOKEN")

provider = IBMQ.load_account()

backend = provider.get_backend('ibmq_quito')

optimized_circuit = qiskit.transpile(quantum_circuit, backend)

optimized_circuit.draw()

# run in real hardware

job = backend.run(optimized_circuit)

# this is where I put my code



retrieved_job = backend.retrieve_job(job.job_id())

result = retrieved_job.result()

print(result.get_counts())

Reference here