Information Center

Cloud computing development: detailed explanation of Python 3 random number function uniform() method

  

describe

The Python 3 uniform() method will randomly generate the next real number, which is in the range of [x, y].

grammar

The syntax of the uniform() method is as follows:

import random

random.uniform(x, y)

Note: Uniform() cannot be accessed directly. You need to import the random module and call the method through the random static object.

parameter

X -- the minimum value of the random number, including this value.

Y -- the maximum value of the random number, including this value.

Return value

Returns a floating point number N, the value range is if x

example

The following shows an example of using the uniform() method:

 Use the uniform() method instance

The output result of the above instance is:

 Use the uniform() method instance to run the output results