Random number generation

Cards (4)

  • To the outside observer, it would appear as if computers are capable of generating truly random numbers, but they are not. They generate pseudorandom numbers based on an algorithm, and predictable patterns become apparent when very large sequences of numbers are generated and analysed.
  • To generate random numbers in Python need to import code from a module (or library) called random. In this case you will use the randint function from this module.
  • Pseudorandom number generators use mathematical algorithms to generate a seemingly random number. These algorithms are highly predictable, which makes them unsuitable for use in programs that require a level of security.
  • A true random number generator uses unpredictable physical events to generate numbers, such as atmospheric noise.
    The numbers generated from these are unpredictable and are therefore suitable for use in encryption.