Lesson goal: Random numbers

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.

math.random(low,high)

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:

Show a friend, family member, or teacher what you've done!

Here is a share link to your code:

Does your code work? Want to run it on your iPhone?

Here's your code:

Use [Control]-[C] (Windows) or [⌘]-[C] (MacOS) to copy your code.

Paste it using [Control]-[V] (Windows) or [⌘]-[V] (MacOS) into
this page