Can computers generate truly random numbers? No. Because the algorithm (and the computer) are deterministic. In Python the random numbers are “pseudo random” numbers. Internally Python “seeds” its pseudo-random number generator with a seed and then generates a sequence of numbers based on that seed that are sampled from some distribution, typically a uniform distribution.
The implication is that if you know the seed and the algorithm you can predict the sequence of numbers.
This can actually be really critical for debugging. So languages typically allow you to set the seed.
>>> from random import seed
>>> help(seed)
Help on method seed in module random:
seed(a=None, version=2) method of random.Random instance
Initialize internal state from hashable object.
None or no argument seeds from current time or from an operating
system specific randomness source if available.
If *a* is an int, all bits are used.
For version 2 (the default), all of the bits are used if *a* is a str,
bytes, or bytearray. For version 1 (provided for reproducing random
sequences from older versions of Python), the algorithm for str and
bytes generates a narrower range of seeds.
Setting the seed doesn’t result in the same number over and over again. But we will get the same sequence of numbers.
>>> seed(2)
>>> randint(0, 359)
28
>>> randint(0, 359)
46
>>> seed(2)
>>> randint(0, 359)
28
>>> randint(0, 359)
46
So where we can get true randomness? For many applications you can use random.org.