from qiskit import *

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

circuit = QuantumCircuit(qr, cr)

%matplotlib inline 
circuit.draw(output='mpl')

# the quantum circuit has two qubits. they are indexed as qubits 0 and 1
circuit.h(0)
circuit.cx(0,1) # order is control, target
circuit.measure([0,1], [0,1]) # qubits [0,1] are measured and results are stored in classical bits [0,1] in order
circuit.draw(output='mpl')

simulator = Aer.get_backend('qasm_simulator')

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

from qiskit.visualization import plot_histogram
import qiskit.quantum_info as qi

plot_histogram(result.get_counts(circuit))

from qiskit import IBMQ

IBMQ.save_account('e9857a49c124d22110b0c577754d160e984ce3f01e5ef110ae6295f3f6c4a6f337a129dfdcb5a1191a9b8c69317e9ae32ed4d196b744571d45453db7fb56d933')

IBMQ.load_account()

provider = IBMQ.get_provider(hub = 'ibm-q')

qcomp = provider.get_backend('ibm_brisbane')



import qiskit.tools.jupyter
%qiskit_job_watcher

job = execute(circuit, backend=qcomp)

result = job.result()
plot_histogram(result.get_counts(circuit))

