您的位置:首页 > Python > python随机数如何求和

python随机数如何求和

来源:https://www.py.cn/jishu/jichu/18630.html 热度:499   更新时间:2022-08-30

文章导读:python随机数求和的方法:1、使用“import random”导入random模块2、使用“random.randint()”可以产生随机数。用for循环生成多个随机数,然后相加就可以了执行结果如下:。

python随机数求和的方法:

1、使用“import random”导入random模块

QQ截图20200602170849.png

2、使用“random.randint()”可以产生随机数。用for循环生成多个随机数,然后相加就可以了

QQ截图20200602170905.png

执行结果如下:

QQ截图20200602171000.png