1

Given below is the code I ran on jupyter notebook I have created account on IBM for this project. Please help !

import qiskit as q
import numpy as np
import matplotlib
%matplotlib inline

circuit = q.QuantumCircuit(2 , 2) # 2 qubit and 2 classical bits 
#currently: (0,0)
circuit.x(0)
#now : (1,0)
circuit.cx(0 , 1)  #cnot gate , controlled NOT gate , it flips 2nd bit if 1 quibit is 1
# now : (1 , 1)
circuit.measure([0,1],[0,1])  # map quibit to bits
circuit.draw(output="mpl")  # ascii of circuit

from qiskit import IBMQ
IBMQ.save_account('MY_TOKEN_NUMBER',overwrite=True)  #save your creds
IBMQ.load_account()
#got this as output to prev line of code :
# <AccountProvider for IBMQ(hub='ibm-q', group='open', project='main')>

provider = IBMQ.get_provider(q.providers.baseprovider)
susmit410
  • 9
  • 4

1 Answers1

2

The provider is returned from the load_account() call and then this is used to select a backend. Backends are selected by passing a string to the method provider.get_backend(). Therefore, I believe the code you need is :

provider = IBMQ.load_account()
backend = provider.get_backend('ibmq_qasm_simulator')

I would recommend having a look in the README for more information on how to load your account.

Also, when you have saved your account details once you don't need to keep re-saving them, you can simply call IBMQ.load_account().

met927
  • 311
  • 3
  • 9