The "Pick Random" Block
CreatiCode last edited by creaticodeteacher2-mail
A random number is a number that can not be predicted. For example, if someone says "1, 2, 3, ", then you can probably guess the next number will be 4. This sequence of numbers has a clear pattern to it, so it is not random.
However, if someone says “3, 1, 2,”, it will be not so easy to guess what’s the next number. It appears the numbers are randomly chosen.
You can ask the computer to give you a new number randomly within a range using this reporter block from the “Operators” category:
It takes 2 numbers as inputs, and these 2 numbers define a range to choose from. For example, if the inputs are 1 and 5, then we have 5 numbers to choose from: 1, 2, 3, 4 and 5.
Every time we run this block, a new number is chosen, and we do not know which of these 5 numbers the computer will choose for us next:
Note that all the numbers within the range you specify are equally likely to be chosen. For example, if the range is 1 to 2, then if you try a lot of times, then the number of times you get 1 is about the same as the number of times you get 2.
You can verify this by getting 100 random numbers between 1 and 2, and see if you get about 50 of each number.