from qiskit import *
from qiskit.visualization import plot_bloch_multivector, visualize_transition, plot_histogram

# Create a quantum circuit with a single qubit
# The default initial state of qubit will be |0> or [1,0]
qc = QuantumCircuit(1)

#Apply the Pauli X-gate on the qubit to make the input to y gate as |1>
qc.x(0)

#Apply the Pauli y-gate on the |1> qubit
qc.y(0)

#Draw the circuit
# qc.draw()
qc.draw('mpl')

#Get the backend for the circuit (simulator or realtime system)
backend = Aer.get_backend('statevector_simulator')


#execute the circuit using the backend
out = execute(qc,backend).result().get_statevector()

#plot the result as a bloch sphere visualization
plot_bloch_multivector(out)

# visualize the output as an animation
visualize_transition(qc)

#execute the circuit and get the plain result
out = execute(qc,backend).result()
#getting the count of the result
counts = out.get_counts()
#plotting the histogram
plot_histogram(counts)

