teach-ict.com logo

THE education site for computer science and ICT

1. Introduction

Random numbers are widely used in computer programming. So it is important that you know how to create them in the computer language of your choice.

Here are some examples that use random numbers

  • The amount of damage that a monster hits you for in a computer game
  • Picking a lottery ticket (we shall use this in this section)
  • Creating a random set of values for testing code
  • 'Monte Carlo' testing. Where a simulation is run with a random starting conditions each time - weather forecasters use this to see how accurate their forecast is likely to be.
  • Encryption - creating massive random keys to scramble data

We are going to use Python 3 to show how random numbers are produced. A number of Python demo files are included in page 10 so you can run the code on your own computer.