Python is a batteries-included language, meaning it includes many many useful features in the standard library included with your Python installation. One of the handy libraries is
random that offers a few convenient functions for doing pseudo-random things.
Why pseudo-random? Well, computers are pretty much dependent on being told what to do, and you can’t tell them to do something that is actually random. So, instead, they use some very fancy maths to generate a number that is effectively random enough.
If you want to pull back the curtain, you can tinker with setting the
seed value. You will find that…