.random()

The .random() method accepts no parameters and returns a pseudo-random floating-point number between 0.0 and 1.0.

Syntax

random.random()

Codebyte Example

It is possible to generate a pseudo-random float between 0 and a given number by multiplying it by random.random():

Code
Output
Loading...

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn Python on Codecademy