A loaded die doesn’t land on every outcome equally often: chances[i] is how often outcome i comes up, and the chances add up to 1. A computer can only roll fair: random.random() gives a roll, a number from 0 up to (not including) 1, every value equally likely. Write pick(chances, roll): the outcome (its index, from 0) that this roll gives, so that over many rolls each outcome comes up as often as its chance. The same roll always gives the same outcome.
A loaded die as a wheel: one wedge per outcome, each as wide as its chance. The computer can’t spin a loaded wheel; all it has is a fair roll, a number from 0 up to 1. That roll is how far round the rim the wheel stops. Your pick() turns a roll into an outcome.
pick(chances, roll)| chances | how often each outcome comes up, adding up to 1 | e.g. [0, 1, 0] |
| roll | a fair random number, 0 <= roll < 1 | e.g. 0.05 |
| returns | the outcome (an index) this roll gives | |