.random()

StevenSwiniarski's avatar
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():

Code
Output
Loading...

All contributors

Contribute to Docs

Learn Python on Codecademy