Lesson goal: Random numbers

Previous: Using square roots | Home | Next: Reading text from the keyboard

Along with the math calculations that computers know how to perform, they also typically know how to deliver a random number. A random number is a number that is "unpredictable," meaning it is difficult for anyone to say for sure what number will be produced. This allows for one to add an element of "unpredictability" in their programs.

This lesson will introduce you to random numbers, and how they might be used in a computer program.
Move the mouse over a dotted box for more information.

Now you try. Type print(math.random(1,10)). Run this a few times. You'll see a different number between 1 and 10 each time.

Type your code here:

See your results here: