AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Make it work

Week 20 · Unit 8: Be an innovator · 3 lessons
2

Random numbers

Computing 4: Unit 8, pp. 104–122
GoalUse the pick random block to show a number chosen by chance and say which numbers are possible.
New words
random · chosen by chance, so nobody can know the result before it happenspick random · a block that gives a random whole number between two numbersshow number · a block that shows a number on the LED display
Explanation

A random number is chosen by chance. The block pick random (1) to (4) gives one whole number from 1 to 4. It can give 1 or 4 as well as the numbers between them. Each number is equally likely, but you cannot know which one will come next. Put the pick random block inside the show number block. After showing the number, pause so that people can read it, and then clear the screen. The pick random block is in the Math group. Random numbers are used in games and to make fair choices, such as who goes first. Over a few tries the results are not even, but over many tries each number comes up about equally often.

show numberpick random1to4
Worked examples
show numberpick random5to15pause (ms)3000clear screenon buttonApressed
An exercise spinner. When button A is pressed, the board shows how many star jumps to do: a random number from 5 to 15. The number stays for 3 seconds, then the screen clears and the next person presses A.
BlockSmallestLargestHow many results
pick random 1 to 4144
pick random 5 to 1551511
Count the possible results. Pick random 1 to 4 can give 1, 2, 3 or 4, which is 4 numbers. Pick random 5 to 15 can give every number from 5 to 15. That is 15 − 5 + 1 = 11 different numbers.
024681234times picked
Aisha pressed a who-goes-first program (pick random 1 to 4) 20 times and made a tally. The numbers did not come up 5 times each. That is normal for random numbers: each one is equally likely, but the results of a few tries are uneven.
Class activity

Paper random (with family): write the numbers 1, 2, 3 and 4 on four slips of paper and fold them. Shake them in a bag or a box. One person picks a slip without looking, everyone sees the number, and the slip goes back in the bag. Do this 20 times and make a tally chart. Are all four numbers picked exactly 5 times? Why not? Put your results together with another family’s results: do the numbers get closer to equal?

Practice
1
Which numbers can the block pick random 3 to 6 give?
2
How many different numbers can the block pick random 10 to 20 give?
3
This program picks who goes first among 4 players. What must you change to make it work for 6 players?
show numberpick random1to4pause (ms)2000clear screenon buttonBpressed
4
Write the algorithm for this gadget: when button B is pressed, show a random number from 1 to 3 for 2 seconds and then clear the screen.