from qiskit import QuantumCircuit,BasicAer,Aer,transpile,execute
from qiskit.visualization import *

qc=QuantumCircuit(2)
qc.h(0)
qc.cx(0,1)
qc.measure_all()
qc.draw(output="mpl")


backend=Aer.get_backend('qasm_simulator')
job=execute(qc,backend,shots=1024)
result=job.result()
counts=result.get_counts()
print(counts)

# For the statevector ,no  measurements 
qc=QuantumCircuit(2)
qc.h(0)
qc.cx(0,1)
qc.draw(output="mpl")

backend=Aer.get_backend('statevector_simulator')
job=execute(qc,backend,shots=1024)
result=job.result()
sv=result.get_statevector()
sv.draw(output="latex")

plot_state_qsphere(sv,show_state_phases=True)

plot_state_city(sv)

qc=QuantumCircuit(2)
qc.x(0)
qc.h(0)
qc.cx(0,1)
qc.measure_all()
qc.draw(output="mpl")


backend=Aer.get_backend('qasm_simulator')
job=execute(qc,backend,shots=1024)
result=job.result()
counts=result.get_counts()
print(counts)

# For the statevector ,no  measurements 
qc=QuantumCircuit(2)
qc.x(0)
qc.h(0)
qc.cx(0,1)

qc.draw(output="mpl")

backend=Aer.get_backend('statevector_simulator')
job=execute(qc,backend,shots=1024)
result=job.result()
sv=result.get_statevector()
sv.draw(output="latex")

plot_state_qsphere(sv,show_state_phases=True)

plot_state_city(sv)

qc=QuantumCircuit(2)

qc.h(0)
qc.x(1)
qc.cx(0,1)
qc.measure_all()
qc.draw(output="mpl")


backend=Aer.get_backend('qasm_simulator')
job=execute(qc,backend,shots=1024)
result=job.result()
counts=result.get_counts()
print(counts)

# For the statevector ,no  measurements 
qc=QuantumCircuit(2)

qc.h(0)
qc.x(1)
qc.cx(0,1)

qc.draw(output="mpl")

backend=Aer.get_backend('statevector_simulator')
job=execute(qc,backend,shots=1024)
result=job.result()
sv=result.get_statevector()
sv.draw(output="latex")

plot_state_qsphere(sv,show_state_phases=True)

plot_state_city(sv)

qc=QuantumCircuit(2)
qc.x(0)
qc.h(0)
qc.x(1)
qc.cx(0,1)
qc.measure_all()
qc.draw(output="mpl")


backend=Aer.get_backend('qasm_simulator')
job=execute(qc,backend,shots=1024)
result=job.result()
counts=result.get_counts()
print(counts)

# For the statevector ,no  measurements 
qc=QuantumCircuit(2)
qc.x(0)
qc.h(0)
qc.x(1)
qc.cx(0,1)

qc.draw(output="mpl")

backend=Aer.get_backend('statevector_simulator')
job=execute(qc,backend,shots=1024)
result=job.result()
sv=result.get_statevector()
sv.draw(output="latex")

plot_state_qsphere(sv,show_state_phases=True)

plot_state_city(sv)

qc=QuantumCircuit(1)
qc.h(0)
qc.draw(output="mpl")

backend=Aer.get_backend('statevector_simulator')
job=execute(qc,backend,shots=1024)
result=job.result()
sv=result.get_statevector()
sv.draw(output="latex")

plot_state_qsphere(sv,show_state_phases=True)

qc=QuantumCircuit(1)
qc.x(0)
qc.h(0)
qc.draw(output="mpl")

backend=Aer.get_backend('statevector_simulator')
job=execute(qc,backend,shots=1024)
result=job.result()
sv=result.get_statevector()
sv.draw(output="latex")

plot_state_qsphere(sv,show_state_phases=True)

qc=QuantumCircuit(1)
qc.h(0)
qc.sdg(0)
qc.draw(output="mpl")

backend=Aer.get_backend('statevector_simulator')
job=execute(qc,backend,shots=1024)
result=job.result()
sv=result.get_statevector()
sv.draw(output="latex")

plot_state_qsphere(sv, show_state_phases=True)

qc=QuantumCircuit(3)
qc.h(0)
qc.cx(0,1)
qc.cx(0,2)
qc.draw(output="mpl")

backend=Aer.get_backend('statevector_simulator')
job=execute(qc,backend,shots=1024)
result=job.result()
sv=result.get_statevector()
sv.draw(output="latex")

plot_state_qsphere(sv, show_state_phases=True)

