This is sort of the opposite of the Quantum Teleportation we have covered earlier. Here you use quantum bits to transfer classical bits:
We have all the building blocks we need from the previous episode, so let me just show you the additional code:
#Alice bits
a1=1
a2=1
print("Alice bits:",a1,a2)
#Initialize inputs
q=[[1],[0],[0],[0]]
#Build circuit
U=kron(H,I)
U=mult(CNOT,U)
#Encode bits
if a2==1:
U=mult(kron(X,I),U)
if a1==1:
U=mult(kron(Z,I),U)
#Run circuit
q=mult(U,q)
#Bob applies gates
q=mult(CNOT,q)
q=mult(kron(H,I),q)
#Bob measurements
b1=qbit(0,M(q))
q=qbitset(0,b1,q)
b2=qbit(1,M(q))
q=qbitset(1,b2,q)
print("Bob measurements:",b1,b2)
So as an example we try to give Bob the bits 1 and 1. Bob does his measurements and this is the result:

