import random random.seed() print random.randrange(1, 10, 1) # generate a number between [1, 10) print random.randint(1, 10) # generate an integer between [1, 10] print random.choice(range(10)) # get a random integer from the list l = range(10) random.shuffle(l) # shuffle the list print l print random.sample(xrange(10), 10) # sample size should less than the size of the list
import random random.seed() print random.random() # generate a random float number between [0, 1) print random.uniform(1, 10) # generate a random float number between [1, 10] with uniform distribution print random.gauss(0, 1) # generate a float number with gauss distribution