from qiskit import *

qr = QuantumRegister(2)

cr = ClassicalRegister(2)

circuit = QuantumCircuit(qr, cr)

%matplotlib inline

circuit.draw(output='mpl')

circuit.h(qr[0])

circuit.draw(output = 'mpl')

circuit.cx(qr[0], qr[1])

circuit.draw(output='mpl')

circuit.measure(qr, cr)

circuit.draw(output='mpl')

simulator = Aer.get_backend('qasm_simulator')

execute(circuit, backend=simulator)

result = execute(circuit, backend=simulator).result()

from qiskit.tools.visualization import plot_histogram

plot_histogram(result.get_counts(circuit))

from qiskit import IBMQ

MY_API_TOKEN = "b32678329f7f6dd426b8cf18f20bea23c2cd056b0bee2b4bcf49744b612e598f20f7170a8da4bfd99b009b6fa59d596edea7a6926fd388be158843d8e******"
IBMQ.save_account(MY_API_TOKEN, overwrite=True)

IBMQ.load_account()

provider = IBMQ.get_provider(hub='ibm-q', group='open', project='main')

provider.backends()

backend = provider.get_backend('ibmq_santiago') 

job =execute(circuit, backend= backend)

from qiskit.tools.monitor import job_monitor

job_monitor(job)

result = job.result()

# plot_histogram

plot_histogram(result.get_counts(circuit))



