Entanglement between 2 qubits

Hello World Quantum Qiskit Hello World
In [1]:
from qiskit import *
In [2]:
qr = QuantumRegister(2)
In [3]:
cr = ClassicalRegister(2)
In [4]:
circuit = QuantumCircuit(qr, cr)
In [5]:
%matplotlib inline
In [6]:
circuit.draw()
Out[6]:
         
q0_0: |0>
         
q0_1: |0>
         
 c0_0: 0 
         
 c0_1: 0 
         
In [7]:
circuit.h(qr[0])
Out[7]:
<qiskit.circuit.instructionset.InstructionSet at 0x1a28852790>
In [8]:
circuit.draw(output='mpl')
Out[8]:
In [9]:
circuit.cx(qr[0],qr[1])
Out[9]:
<qiskit.circuit.instructionset.InstructionSet at 0x1a289546d0>
In [10]:
circuit.draw(output ='mpl')
Out[10]:
In [11]:
circuit.measure(qr, cr)
Out[11]:
<qiskit.circuit.instructionset.InstructionSet at 0x1a28993b90>
In [12]:
circuit.draw(output = 'mpl')
Out[12]:
In [13]:
simulator = Aer.get_backend('qasm_simulator')
In [14]:
result = execute(circuit, backend = simulator).result()
In [15]:
from qiskit.tools.visualization import plot_histogram 
In [16]:
plot_histogram(result.get_counts(circuit))
Out[16]:
In [17]:
IBMQ.load_account()
Out[17]:
<AccountProvider for IBMQ(hub='ibm-q', group='open', project='main')>
In [18]:
provider = IBMQ.get_provider('ibm-q')
In [19]:
qcomp = provider.get_backend('ibmq_16_melbourne')
In [20]:
job = execute(circuit, backend=qcomp)
In [21]:
from qiskit.tools.monitor import job_monitor
In [22]:
job_monitor(job)
Job Status: job has successfully run
In [26]:
result = job.result()
In [27]:
plot_histogram(result.get_counts(circuit))
Out[27]: