Thursday, 5 July 2012

Random Number Functions: in Python

Function
Returns(description)
Choice(seq)
A random item from a list, tuple, or string
Randrange([start,] stop[,step])
A randomly selected element from range(start, stop, step)
Random()
A random float r, such that 0 is less than or equal to r and r is less than 1
Seed([x])
Sets the integer starting value used in generating random numbers. Call this function before calling any other random module function. Returns none.
Shuffle(lst)
Randomizes the items of a list in place. Returns none.
Uniform(x, y)
A random float r, such that x is less than or equal to r and r is less than y.

No comments:

Post a Comment