What is the difference between superposition and a function that randomly returns a value? I am struggling to understand a few things about quantum physics. One of those things is superposition. If a photon (for example) is in superposition, there is an equal probability that it will exist in one state or another. I can write a computer program - a function call, let's say - that does the exact same thing. It will return a value in one of two states that is random (at least to the observer) yet equally probable in its outcome. So how is that our example photon is in "superposition" while my program isn't?
 A: The problem is more the difficulty in comprehending the counter-intuitive concepts of quantum physics. The photon is in the two states, until the observer breaks the superposition by observing the photon, doing so "reveals" one of the two states randomly. This is true randomness, as there is currently no way to predict the outcome of the observation, nor to control it.
A classic computer usually uses a mathematical formula to generate pseudo-random numbers. A seed, one or more numbers, are provided to the function, then the seed is computed thanks to the formula to provide a pseudo-random number. The function has been built in a way that random numbers are as much as possible uniformly distributed. But providing the same seed to the function will generate the same pseudo-random number. These "random" numbers can be predicted (see Random numbers from computers were never really random, until now that explains how a computer could generate true randomness).
As you can see a single random number generation from a computer requires a huge number of operations at the "quantum" / atomic level. While the observation of the state of a photon (the superposition "breakage") is ... indivisible (at this time).

So how is that our example photon is in "superposition" while my program isn't?

Being in superposition means that at a given time $t < t_0$ the program would hold (at least) two different states, say $s_1$ and $s_2$. And at $t_0$ the function renders either $s_1$ or $s_2$ randomly (or pseudo-randomly). So "superposition" can be simulated by a program.
But the word "superposition", actually "quantum superposition", is a term of quantum physics to describe properties at the particle level ; it doesn't apply to a program behavior, and even if the function would simulate superposition, it's not called superposition.
