Using the Python random library:

Python's random library has a number of useful methods:

>>> import random

>>> # get a random number between 2 and 9 (incuding 2 and 9):  random.randint(low,high)
>>> print(random.randint(2,9))
4
>>> print(random.randint(2,9))
9

>>> # get a random floating point number between 0 and 1.0:  random.random()
>>> print(random.random())
0.9715282355486393

>>> # choose a random element of a list:  random.choice(alist)
>>> print(random.choice([1,'hello','whatever',12]))
hello
>>> print(random.choice([1,'hello','whatever',12]))
12