from qiskit import *

from qiskit import QuantumCircuit, assemble, transpile, Aer, IBMQ
from qiskit.tools.jupyter import *
from qiskit.visualization import *
#quantum_widgets import *
from math import pi, sqrt
from qiskit.visualization import plot_bloch_multivector, plot_histogram

qr = QuantumRegister(2)

cr = ClassicalRegister(2)

circuit = QuantumCircuit(qr, cr)

%matplotlib inline

circuit.draw()

circuit.h(0)

circuit.draw(output='mpl')

circuit.draw()

circuit.cx(0,1) #control x 2 qubit operator

circuit.draw()

circuit.measure(qr,cr)

circuit.draw()

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))

# load account
IBMQ.load_account()

provider = IBMQ.get_provider('ibm-q') #below one recommended

# Hot fix, for open machines
provider = IBMQ.get_provider(hub='ibm-q', group='open', project='main')
provider.backends()

qcomp = provider.get_backend('ibmq_bogota')

job = execute(circuit, backend=qcomp)

from qiskit.tools.monitor import job_monitor

job_monitor(job)

result = job.result()

plot_histogram(result.get_counts(circuit))