+ 1
How can I get a random value in python?
3 Answers
+ 4
Highly depends on what you want to do. Look at python's random module. It has functions for random integers, random doubles, random selections from lists, random Gaussian distributed numbers...
+ 2
First you must import random module in python.
then you may use :
random.random()# random number between 0 and 1
random.uniform(x,y) # here x and y are two numbers and this generates a random float number between x and y
or
random.randint(x,y)# it generates random integer between x and y.
0
use the random function
for example:
import random
for x in range(10):
print random.randint(1,200)