Random Generation from List_Random Numbers.py

Sign up Free. Don't forget to check out our challenges, lessons, solve and learn series and more ...

Code Snippet

import random

#Generate a Random Number from 0 to 99
my_number = random.randrange(100)

#Generate a random item from a predefined list
secret_colour = ["blue", "red", "yellow"]
random_index = random.randrange(3)

#Generate a random floating point number from 0 to 1
my_number = random.random()


Try it yourself