Python Random uniform() Method

❮ Random Methods


Example

Return a random number between, and included, 20 and 60:

import random

print(random.uniform(20, 60))
Try it Yourself »

Definition and Usage

The uniform() method returns a random floating number between the two specified numbers (both included).


Syntax

random.uniform(a, b)

Parameter Values

Parameter Description
a Required. A number specifying the lowest possible outcome
b Required. A number specifying the highest possible outcome

❮ Random Methods

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.