pip install pylatexenc

!pip install qiskit

from qiskit import IBMQ, Aer, QuantumCircuit, ClassicalRegister, QuantumRegister, execute
from qiskit.providers.ibmq import least_busy
from qiskit.quantum_info import Statevector
from qiskit.visualization import plot_histogram

# Create a Quantum Register called "qr" with 2 qubits.
qr = QuantumRegister(2,'qr')

# Create a Classical Register called "cr" with 2 bits.
cr = ClassicalRegister(2,'cr')


qc =  QuantumCircuit(qr,cr)

# Add the H gate in the Qubit 1, putting this qubit in superposition.

qc.h(qr[1])

# Add the CX gate on control qubit 1 and target qubit 0, putting the qubits in a Bell state i.e entanglement
qc.cx(qr[1], qr[0])


# Add a Measure gate to see the state.
qc.measure(qr[0],cr[0])
qc.measure(qr[1],cr[1])

# Compile and execute the Quantum Program in the ibmqx5
qc.draw(output='mpl')

qasm_simulator = Aer.get_backend('qasm_simulator')
shots = 1024
result = results = execute(qc, backend=qasm_simulator, shots=shots).result()

Ans=result.get_counts()

plot_histogram(Ans)

