from qiskit import *
#Comando para que las graficas se vean en el notebook
%matplotlib inline

qr = QuantumRegister(2)
cr = ClassicalRegister(2)

circuit = QuantumCircuit(qr, cr)

circuit.draw()

circuit.draw(output='mpl')

qr = QuantumRegister(2, 'quantum')
cr = ClassicalRegister(2, 'classical')

circuit.draw()

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

backend = Aer.get_backend('qasm_simulator')

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

from qiskit.tools.visualization import plot_histogram

plot_histogram(result.get_counts(circuit))

'''
    El IMB_TOKEN se puede obtener en: https://quantum-computing.ibm.com/account
'''

#IBMQ.save_account('IMB_TOKEN', overwrite=True)

IBMQ.load_account()

provider = IBMQ.get_provider(group='open')
provider.backends()


provider = IBMQ.get_provider('ibm-q')
qcomp = provider.get_backend('ibmqx2')

job = execute(circuit, backend=qcomp)

from qiskit.tools.monitor import job_monitor

job_monitor(job)

result = job.result()

plot_histogram(result.get_counts(circuit))

