当前位置:首页 > Software > Python > 正文内容

random库

Doraemon6年前 (2020-02-16)Python6598

random()            生成一个[0.0,1.0)之间的随机小数

randint(a,b)     生成一个[a,b]之间的整数

uniform(a,b)     生成一个[a,b]之间的随机小数

对random库的引用方法与math库一样,采用下面两种方式实现:

import random    或    from random import*

import random                      from random import* 

random.random()                   uniform(1,10)      

0.23456567                             1.53456775    

扫描二维码推送至手机访问。

版权声明:本文由我的FPGA发布,如需转载请注明出处。

本文链接:https://myfpga.cn/index.php/post/132.html

分享给朋友:
返回列表

上一篇:搜索字符串

下一篇:列表实例

“random库” 的相关文章

Python关于turtle的函数名

Python关于turtle的函数名

turtle.forward(distance)                   向当前画笔方向移动distance像素长度turtle.backward(distance)              向当前画笔相反方向移动distance像素长度turtle.right(degree)    ...

math库的使用

math库的使用

math库包括4个数学常数math.pi      圆周率math.e       自然对数math.inf     正无穷大,负无穷大为-math.infmath.nan     非浮点数标记math库常用函数math.cell(x)      向上取整,返回不小于x的最小整数math.facto...

for循环

for循环

range()函数range(start,end,step)range()函数返回一个可迭代对象(可理解为一个序列,序列中的数包括start,不包括end)例如range(1,101),返回1-100的序列。range(101),范围0-100的序列。range(1,100,2),返回1,3,5.....

顺序查找

顺序查找

如果需要查找某个特定值的位置(以便能够替换或删除它),可以直接使用index方法。searchedValue=100 #values是之前定义好的一个列表 if searchedValue in walues:     pos=values.index(searchedValue)     ...

anaconda打不开的解决方法

anaconda打不开的解决方法

报错内容Navigator Error An unexpected error occurred on Navigator start-up Report Please report this ...