0% found this document useful (0 votes)
7 views1 page

Python Random Module

The document describes the Python random module, which provides various methods for generating random numbers and manipulating sequences. Key methods include seed(), randint(), choice(), shuffle(), and several others that generate random numbers based on different statistical distributions. This module is essential for tasks requiring randomness in programming.

Uploaded by

vishal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Python Random Module

The document describes the Python random module, which provides various methods for generating random numbers and manipulating sequences. Key methods include seed(), randint(), choice(), shuffle(), and several others that generate random numbers based on different statistical distributions. This module is essential for tasks requiring randomness in programming.

Uploaded by

vishal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Python has a built-in module that you can use to make random numbers.

The random module has a set of methods:

Method Description
seed() Initialize the random number generator
getstate() Returns the current internal state of the random number generator
setstate() Restores the internal state of the random number generator
getrandbits() Returns a number representing the random bits
randrange() Returns a random number between the given range
randint() Returns a random number between the given range
choice() Returns a random element from the given sequence
choices() Returns a list with a random selection from the given sequence
shuffle() Takes a sequence and returns the sequence in a random order
sample() Returns a given sample of a sequence
random() Returns a random float number between 0 and 1
uniform() Returns a random float number between two given parameters
Returns a random float number between two given parameters, you can also set a
triangular()
mode parameter to specify the midpoint between the two other parameters
Returns a random float number between 0 and 1 based on the Beta distribution (used
betavariate()
in statistics)
Returns a random float number based on the Exponential distribution (used in
expovariate()
statistics)
gammavariate() Returns a random float number based on the Gamma distribution (used in statistics)
Returns a random float number based on the Gaussian distribution (used in
gauss()
probability theories)
Returns a random float number based on a log-normal distribution (used in
lognormvariate()
probability theories)
Returns a random float number based on the normal distribution (used in probability
normalvariate()
theories)
Returns a random float number based on the von Mises distribution (used in
vonmisesvariate()
directional statistics)
Returns a random float number based on the Pareto distribution (used in probability
paretovariate()
theories)
weibullvariate() Returns a random float number based on the Weibull distribution (used in statistics)

You might also like