Skip to content

Random integer in range (math_random_int)

What it does: Returns a random integer including both bounds.

math_random_int

Inputs

  • FROM: lower limit.
  • TO: upper limit.

Output

  • number (int)

Tips

  • The block uses random.randint(FROM, TO), so both limits are included.
  • The generator will automatically add import random.

When to use it

For example for random position, draw or variable delay. For the dice, set the lower limit to 1 and the upper limit to 6. Both limits should be whole numbers and the lower limit must not be greater than the upper limit.

Each time the block is executed, another random value is generated; may be the same as the previous one. If you need to use it in multiple places without change, first save it in variable.