Py.–Random

 0    12 flashcards    sir
download mp3 print play test yourself
 
Question Answer
A random item from a list, tuple, or string.
start learning
choice(seq)
A randomly selected element from range(start, stop, step).
start learning
randrange ([start,] stop [, step])
A random float r: 0<=r<1
start learning
random()
Sets the integer starting value used in generating random numbers. Call this function before calling any other random module function. Returns None.
start learning
seed([i'x])
Randomizes the items of a list in place. Returns None.
start learning
shuffle(lst)
A random float r, belonging to [x; y)
start learning
uniform(x, y)
Returns a list with a random selection from the given sequence
start learning
choices(sequence, weights=None, cum_weights=None, k=1)
returns a list with a randomly selection of a specified number of items from a sequnce.
start learning
sample(sequence, k)
Returns the current internal state of the random number generator
start learning
getstate()
Returns a number representing the random bits
start learning
getrandbits()
Get random integer in <start; stop>.
start learning
randint(start, stop)
setstate (f'state)
start learning
setstate(f'state)

You must sign in to write a comment