Python random snippets

Documentation

Import directives


In [ ]:
import random

Return a random floating point number in the range [0.0, 1.0)


In [ ]:
random.random()

Return a random integer from a given interval


In [ ]:
min_value = 0
max_value = 10
random.randint(min_value, max_value)