The random.uniform()
method in Python is used to return a random floating-point number that is greater than or equal to the specified low boundary, and less than or equal to the specified high boundary.
random.uniform(a, b)
Parameter | Description |
---|---|
a |
a is the number that specifies the lowest boundary the return value should have; this parameter is required. |
b |
b is the number that specifies the highest boundary the return value should have; this parameter is required. |
Let’s look at a very simple way to use the random.uniform()
method. Let us write a code to generate a random float number starting from 5 and ending at 10.
import randomprint(random.uniform(5,10))
random
module.random.uniform()
method to return a random float number starting from 5 and ending at 10.