!pip install qiskit

from qiskit import BasicAer
from qiskit import QuantumRegister ,ClassicalRegister ,QuantumCircuit ,execute
from qiskit.tools.visualization import plot_histogram ,circuit_drawer
from numpy import pi

qr = QuantumRegister(3)
cr = ClassicalRegister(3)
qc = QuantumCircuit(qr,cr)

qc.u3(pi/7,13*pi/4,0,qr[0])
qc.h(qr[1])
qc.cx(qr[1],qr[2])
qc.cx(qr[0],qr[1])
qc.h(qr[0])
qc.cx(qr[1],qr[2])
qc.cz(qr[0],qr[2])
qc.barrier()

qc.measure(qr,cr)

qc.draw()

backend = BasicAer.get_backend("qasm_simulator")
job = execute(qc,backend = backend, shots = 8192)

res = job.result()
counts1 = res.get_counts()
counts1

plot_histogram(counts1)

backend1 = BasicAer.get_backend("statevector_simulator")

qr = QuantumRegister(1)
qc = QuantumCircuit(qr,cr)

qc.u3(pi/7,13*pi/4,0,qr[0])
job = execute(qc,backend=backend1)

res = job.result()
message = res.get_statevector(qc,decimals=3)
message

from numpy import abs

prob0=(abs(message[0]))**2
prob0

prob1=(abs(message[1]))**2
prob1

prob_bob_0=0.232+0.245+0.238+0.237
prob_bob_0

prob_bob_1=0.013+0.012+0.012+0.011
prob_bob_1

