Description
## The uniform() method will randomly generate the next real number, which is in the range [x, y].Grammar
The following is the syntax of the uniform() method:import random random.uniform(x, y)
staticobject.
Parameters
x -- The minimum value of the random number. y -- The maximum value of the random number.Return value
Returns a floating point number.Example
The following shows an example of using the uniform() method:#!/usr/bin/python # -*- coding: UTF-8 -*- import random print "uniform(5, 10) 的随机数为 : ", random.uniform(5, 10) print "uniform(7, 14) 的随机数为 : ", random.uniform(7, 14)
uniform(5, 10) 的随机数为 : 6.98774810047 uniform(7, 14) 的随机数为 : 12.2243345905
Special recommendation: "php Programmer Toolbox" V0.1 version download
2. 3.Detailed explanation of uniform() based on Python
The above is the detailed content of Detailed explanation of Python basics uniform(). For more information, please follow other related articles on the PHP Chinese website!