Navigation

    CreatiCode Scratch Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode

    The "Pick Random" Block

    2D Blocks
    1
    1
    1486
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • info-creaticode
      CreatiCode last edited by admin

      Introduction

      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.

       

      The “Pick Random” Block

      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:

       

      All Numbers in Range Are Equally Likely to be Chosen

      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.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post