from qiskit import QuantumCircuit, QuantumRegister

# approach 1:
qr = QuantumRegister(1) # QuantumRegister(1) would output QuantumRegister(1, 'q0')
qr

QuantumCircuit(qr)

type(QuantumCircuit(qr))

QuantumCircuit(qr).draw() # better than nothing - but it looks empty for now as we are 
                          # applying any gates to it

QuantumCircuit(1).draw() # this has the same effect

QuantumCircuit(1,1).draw()

# Create a quantum register with one qubit
qr = QuantumRegister(1)

# Create a quantum circuit with the quantum register
circuit = QuantumCircuit(qr)

# Apply the X gate to the first qubit
circuit.x(qr[0])

# Draw the circuit
circuit.draw('mpl') # what does mpl do?
                    # mpl: images with color rendered purely in Python using matplotlib.

qc = QuantumCircuit(1,0)
qc.x(0)
qc.draw('mpl')

qc = QuantumCircuit(1,1) # adding a classical bit 
qc.x(0)
qc.draw('mpl')

qc = QuantumCircuit(1)
qc.y(0)
qc.draw('mpl')

qc = QuantumCircuit(1)
qc.z(0)
qc.draw('mpl')

qc = QuantumCircuit(2,0)
qc.draw()

qc.h(0)
qc.draw()

qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.measure([0, 1], [0, 1])
qc.draw('mpl')



from qiskit.visualization import plot_bloch_vector, visualize_transition
from math import sqrt, pi

coords = [1,pi/2,0]  # [Radius, Theta, Phi]
plot_bloch_vector(coords, coord_type='spherical')

qc = QuantumCircuit(1)
qc.y(0)
qc.h(0)
qc.z(0)
qc.draw('mpl')

## Takes 30s # uncomment to run
# %%time ## takes a long time to run this cell, about 30 seconds! 
#        ## it creates a useful animation that shows the effect of quantum gates over time
# visualize_transition(qc)

