# NodeBox

Create visual output with Python programming code
Home Download Reference Tutorial Library Gallery About

# Reference | random()

Syntax |
    random(v1=None, v2=None)
Description | Returns a random number that can be assigned to a variable or a parameter. When no parameters are supplied, returns a floating-point (decimal) number between 0.0 and 1.0. When one parameter is supplied, returns a number between 0 and this parameter. When two parameters are supplied, returns a number between the first and the second parameter. The random() command is useful for all sorts of operations, from random colors to lines with a random width.
Returns | a random number (either an integer or floating-point) within the given boundaries
Example |
    r = random() # returns a float between 0 and 1
    r = random(2.5) # returns a float between 0 and 2.5
    r = random(-1.0, 1.0) # returns a float between -1.0 and 1.0
    r = random(5) # returns an int between 0 and 5
    r = random(1, 10) # returns an int between 1 and 10

    # sets the fill to anything from
    # black (0.0,0,0) to red (1.0,0,0)
    fill(random(), 0, 0)