pydoc > random

📛 NAME

random - Random variable generators.

🚀 Quick Reference

Use CaseCommandDescription
🎲 Random floatrandom.random()Uniform float in [0.0, 1.0)
🔢 Random integerrandom.randint(a, b)Integer inclusive of both ends
📏 Random from rangerandom.randrange(start, stop[, step])Random item from range, exclusive of stop
🎯 Random choicerandom.choice(seq)Single random element from sequence
🃏 Weighted choicerandom.choices(pop, weights=..., k=1)k elements with replacement
🔀 Shufflerandom.shuffle(x)Shuffle list in place
📋 Samplerandom.sample(pop, k)k unique elements without replacement
🌱 Seedrandom.seed(a)Initialize generator state
📦 Random bytesrandom.randbytes(n)n random bytes
📊 Uniform distributionrandom.uniform(a, b)Float in [a, b) or [a, b]
📈 Gaussianrandom.gauss(mu, sigma)Normal distribution (faster)
📉 Exponentialrandom.expovariate(lambd)Exponential distribution

🔗 MODULE REFERENCE

https://docs.python.org/3.10/library/random.html

The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above.

📝 DESCRIPTION

bytes

integers

sequences

distributions on the real line:

distributions on the circle (angles 0 to 2pi):

General notes on the underlying Mersenne Twister core generator:

📚 CLASSES

_random.Random(builtins.object)
    Random
        SystemRandom

🎲 class Random(_random.Random)

Random(x=None)

Random number generator base class used by bound module functions.

Used to instantiate instances of Random to get generators that don't share state.

Class Random can also be subclassed if you want to use a different basic generator of your own devising: in that case, override the following methods: random(), seed(), getstate(), and setstate(). Optionally, implement a getrandbits() method so that randrange() can cover arbitrarily large ranges.

Method resolution order:

Methods defined here:

Class methods defined here:

Data descriptors defined here:

Data and other attributes defined here:

Methods inherited from _random.Random:

Static methods inherited from _random.Random:

🔒 class SystemRandom(Random)

SystemRandom(x=None)

Alternate random number generator using sources provided by the operating system (such as /dev/urandom on Unix or CryptGenRandom on Windows). Not available on all systems (see os.urandom() for details).

Method resolution order:

Methods defined here:

Inherits all other methods from Random (see above).

📦 FUNCTIONS

The following are module-level functions bound to a default Random instance. See the corresponding Random method documentation for full details.

📊 DATA

__all__ = ['Random', 'SystemRandom', 'betavariate', 'choice', 'choices'...]

📁 FILE

/usr/lib/python3.10/random.py
random
📛 NAME 🚀 Quick Reference 🔗 MODULE REFERENCE 📝 DESCRIPTION 📚 CLASSES
🎲 class Random(_random.Random) 🔒 class SystemRandom(Random)
📦 FUNCTIONS 📊 DATA 📁 FILE

Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-18 16:09 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^