.random()

Published Mar 3, 2022Updated Mar 9, 2022
Contribute to Docs

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():

us
Visit us
code
Hide code
Code
Output
Hide output
Hide output
Loading...

All contributors

Looking to contribute?

Learn Python on Codecademy