win7安装python生成随机数代码分享
import random
def genrand(small, big) :
return small + (big-small) * random.random()
def display(small, big) :
return r'请输入上下限(默认%.2f~%.2f):' % (small, big)
big = 100
small = 0
while True :
try :
s = input(display(small, big)).strip()
if s.lower() == 'exit' :
break
a = s.split()
if a != [] :
big = float(a[1])
small = float(a[0])
rand = genrand(small, big)
print('(%.2f~%.2f): %.3f\n' % (small, big, rand))
except :
print('--Error--\n')
相关文章
面向新手解析python Beautiful Soup基本用法
这篇文章主要介绍了面向新手解析python Beautiful Soup基本用法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下2020-07-07
matplotlib部件之矩形选区(RectangleSelector)的实现
这篇文章主要介绍了matplotlib部件之矩形选区(RectangleSelector)的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2021-02-02


最新评论