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

# Creat a Quantum Circuit with Single Qubit
# With default Initial State as [1,0] or |0>
qc=QuantumCircuit(1)

#Declare the Initial State as [0,1] or |1>
initial_state=[0,1]
qc.initialize(initial_state,0)

# Apply the Pauli x-Gate on the qubit
qc.x(0)

# Draw the Circuit 
# qc.draw()
qc.draw()

#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)

from qiskit import QuantumCircuit
qc = QuantumCircuit(1)
qc.x(0)
qc.draw('mpl')

#Visualize the output as an animation
from qiskit.visualization import visualize_transition
visualize_transition(qc)