from qiskit import *
IBMQ.load_account()

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

circuit=QuantumCircuit(qr,cr)

%matplotlib inline

circuit.draw()

circuit.h(qr[0])

circuit.draw(output='mpl')

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

circuit.draw(output='mpl')

circuit.measure(qr,cr)

circuit.draw()

simulator=Aer.get_backend('qasm_simulator')

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

from qiskit.tools.visualization import plot_histogram
plot_histogram(result.get_counts(circuit))

from qiskit.visualization import plot_state_qsphere
from qiskit.visualization import plot_bloch_multivector

statevector_simulator = Aer.get_backend('statevector_simulator')
result=execute(circuit,statevector_simulator).result()
statevector_results=result.get_statevector(circuit)
plot_bloch_multivector(statevector_results)

plot_state_qsphere(statevector_results)
