#this code block imports some basic libraries we will need
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import cmath as cm
import math
#remember, to execute this block you need to press SHIFT + ENTER

# Use this code block to write methods that construct operators
# as well as perform Inner and Outer products. You should make use
# of the Bra and Ket constructors
def Ket(a,b):
return np.array([[a],[b]])
def Bra(a,b=None):
if b==None:
return (a.conjugate()).transpose()
else:
return np.array([[a,b]])
def Operator():
return
def Inner(B,K): #make sure you know the dimenstions of what you are inputting
return
def Outer(K,B): #make sure you know the dimenstions of what you are inputting
return

# Use this code block to test your new methods inlcuding Bra, Ket
# Operator, Inner Products, Outer Products. Make sure to print
# the results in a format that is easy to understand.

# Use this code block to write your Prob() method

# Use this code block to perform the other requested calculations.

# This code block will install the IBM Qiskit package
!pip install Qiskit

from qiskit.visualization import plot_bloch_vector #you only need to perform this import once
plot_bloch_vector([0,1,0], title="New Bloch Sphere");

```
/root/venv/lib/python3.7/site-packages/qiskit/visualization/bloch.py:402: MatplotlibDeprecationWarning: Axes3D(fig) adding itself to the figure is deprecated since 3.4. Pass the keyword argument auto_add_to_figure=False and use fig.add_axes(ax) to suppress this warning. The default value of auto_add_to_figure will change to False in mpl3.5 and True values will no longer work in 3.6. This is consistent with other Axes classes.
self.axes = Axes3D(self.fig, azim=self.view[0], elev=self.view[1])
/root/venv/lib/python3.7/site-packages/qiskit/visualization/bloch.py:69: MatplotlibDeprecationWarning:
The M attribute was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use self.axes.M instead.
x_s, y_s, _ = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
```

# This code block defines a method PlotKet() which takes a normalized ket as input
# then calculates the Pauli coefficients that are used to plot the ket on the
# Bloch Sphere
def PlotKet(K):
#define Pauli Matrices
sx=np.array([[0,1],[1,0]])
sy=np.array([[0,0+-1j],[0+1j,0]])
sz=np.array([[1,0],[0,-1]])
#get outer product of ket to make projection operator O
B=Bra(K)
O=Outer(K,B)
#calculate coefficients
B=np.trace(O.dot(sx)).real #notice we insuring these values are real
C=np.trace(O.dot(sy)).real
D=np.trace(O.dot(sz)).real
#now plot Bloch Sphere
plot_bloch_vector([B,C,D], title= 'State {}'.format(K));

K=GetRandom()
K=Normalize(K)
PlotKet(K)

# Use this code block to explore the behaivor of the Pauli Matrices
# as operators on kets