pip install -U qiskit==0.36.2

pip install pylatexenc

import qiskit

qiskit.__qiskit_version__

# Copie se API Token no IBMQ e cole aqui
qiskit.IBMQ.save_account('ade2e1cd8926fee57b535ff0761ddac06ce27b6ea7ea0ecb60121d873ccf19578850d46431bbb002e5a64db18657e028fd17ae71b73ce25c57002e2ff579eeb6', overwrite = True)

# Execute esse comando uma vez só
qiskit.IBMQ.load_account()

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

from qiskit import *

qr = QuantumRegister(2)
cr = ClassicalRegister(2)
qc = QuantumCircuit(qr,cr)
qc.h(qr[0])
qc.cx(qr[0],qr[1])
qc.measure(qr[0],cr[0])
qc.measure(qr[1],cr[1])
qc.draw(output='mpl')

simulator = Aer.get_backend('qasm_simulator')

nshots = 8192 # número de "prepara-e-mede"

job = execute(qc, backend = simulator, shots = nshots)

from qiskit.tools.visualization import plot_histogram
plot_histogram(job.result().get_counts(qc))

counts = job.result().get_counts(qc)
counts

counts['00']

# probabilidade
p00 = 0; p01 = 0; p10 = 0; p11 = 0
for j in (0,2):
    for k in (0,2):
        if '00' in counts:
            p00 = counts['00']/nshots
        if '01' in counts:
            p01 = counts['01']/nshots
        if '10' in counts:
            p10 = counts['10']/nshots
        if '11' in counts:
            p11 = counts['11']/nshots
p00, p01, p10, p11

device = provider.get_backend('ibm_nairobi')
from qiskit.tools.monitor import job_monitor

job = execute(qc, backend = device, shots = nshots)
job_monitor(job)

plot_histogram(job.result().get_counts(qc))

counts = job.result().get_counts(qc)
counts

counts['00']

# probabilidade
p00 = 0; p01 = 0; p10 = 0; p11 = 0
for j in (0,2):
    for k in (0,2):
        if '00' in counts:
            p00 = counts['00']/nshots
        if '01' in counts:
            p01 = counts['01']/nshots
        if '10' in counts:
            p10 = counts['10']/nshots
        if '11' in counts:
            p11 = counts['11']/nshots
p00, p01, p10, p11