random.choice(list_name)
random.choice(seq)
Return a random element from the non-empty sequence seq.
import random
list1 = ["Apple", "Banana", "Orange", "Watermelon", "Pear"]
print(random.choice(list1)) #output a random element from list1
random.randrange(stop) | random.randrange(start, stop[, step])
Return a randomly selected element from range(start, stop, step). It includes start but excludes stop and goes by step.
import random
print(random.randrange(5)) #output an integer between 0 (include 0) to 5 (exclude 5)
print(random.randrange(1, 5)) #output an integer between 1 (include 1) to 5 (exclude 5)
print(random.randrange(1, 5, 2)) #output a number between 1 (include 1) to 5 (exclude 5) with increment 2; in this case, the possible outcomes are 1 and 3
random.randint(start, end)
Return a random integer from start to end, both inclusive.
import random
print(random.randint(1, 5)) #output a number between 1 to 5 including 1 and 5.
random.uniform(start, stop)
Return a random floating point number between start and stop. stop may or may not be included.
import random
print(random.uniform(1, 10)) #output a random floating point number between 1 (include 1) to 10 (may or may not include 10.)