# We import the necessary functions from Qiskit
from qiskit.visualization import plot_bloch_multivector, plot_state_qsphere, visualize_transition
from qiskit import QuantumCircuit, Aer, execute

# We create a quantum circuit with one qubit
qc = QuantumCircuit(1)

# We execute the quantum circuit on a statevector simulator backend
backend = Aer.get_backend('statevector_simulator')

# This code executes a quantum circuit `qc` on a backend and stores the result in the `result` variable.
# The `execute` function is used to run the circuit on the specified backend and returns a job object.
# The `result()` method is then called on the job object to get the result of the execution.
result = execute(qc, backend).result()

# We get the statevector of the quantum circuit
statevector = result.get_statevector(qc)

# We plot the statevector on the Bloch sphere
plot_bloch_multivector(statevector)

plot_state_qsphere(statevector, show_state_phases = True, use_degrees = True)

# We add a Hadamard gate to the circuit
qc.h(0)

visualize_transition(qc)