Xiao Bian today to share a random.uniform about Python is for everyone () function tutorial and example are analytic, small series that the content very good, for everyone to share and now has a good reference value, a friend in need with little follow knitting a look
random.uniform () function parses the tutorial example
- Uniform () Function Description
random.uniform (x, y) The method of generating a random real number, it is within [x, y] range.
- uniform () syntax and parameters
2.1 Syntax
# _*_ coding: utf-8 _*_
import random
random.uniform(x, y)
or
# _*_ coding: utf-8 _*_
from random import uniform
uniform(x, y)
Tip: uniform included in the random library, the library needs to import random when you need it.
2.2 Parameters
x - random number minimum value, including the value.
y - is the maximum value of the random number, the value is not included.
Returns a float
3. example
Routine:
# _*_ coding: utf-8 _*_
import random
print("uniform(1 , 6) 的随机返回值为 : ", random.uniform(1 , 6))
print("uniform(10, 16) 的随机返回值为 : ", random.uniform(10, 16))
operation result:
#uniform(1 , 6) 的随机返回值为 : 3.001161523486847
#uniform(10, 16) 的随机返回值为 : 13.70906147017741
We recommend the python learning sites , to see how old the program is to learn! From basic python script, reptiles, django, data mining
And other programming techniques, work experience, as well as senior careful study of small python partners to combat finishing zero-based information projects! everyday
Python programmers explain the timing of technology, sharing some learning methods and the need to pay attention to the small details
summary
That's all for this article, I hope the contents of this paper has some reference value of learning for all of us to learn or work, thank you for the support scripts House.