Making quantum circuits in Python is trivial I hear you say, there are already several packages for this, like Qiskit. Nah, you did not think a calculator had a package manager now, did you? The calculator only has a few standard packages as well as a couple of TI specific ones.
We will need “random” because quantum measurements are probabilistic, and “math” because square root is used in several formulas:
from random import * from math import *
Other than that we will have to do with basic matrices which in Python are just arrays of arrays. That means a qubit will be something like this:
q=[[1/sqrt(2)],[1/sqrt(2)]]
The qubit above is in superposition and if measured will collapse into either “0” or “1”. Given as “[[1],[0]]” or “[[0],[1]]” respectively in our particular Python qubit speak. We are truly inside The Matrix here.
Note that it is pretty cumbersome to key in programs on a calculator so like in the example above variable names will mostly be just one letter and hardly any extra spacing will be added for readability.