from qiskit import *
from qiskit.tools.visualization import plot_histogram

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

circuit = QuantumCircuit(qr,cr)

circuit.decompose().draw(output="mpl", initial_state=True)

circuit.h(qr[0])

circuit.draw(output="mpl")

circuit.cx(qr[0],qr[1])

circuit.draw(output="mpl")

circuit.measure(qr,cr)

circuit.draw(output="mpl")

simulator = Aer.get_backend('qasm_simulator')

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

plot_histogram(result.get_counts(circuit))

