1 Star 0 Fork 0

Wengyk/Python_learning

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
pi.py 369 Bytes
一键复制 编辑 原始数据 按行查看 历史
Wengyk 提交于 2019-03-26 00:12 . add some files
# pi.py
from random import random
from math import sqrt
from time import process_time
DARTS = pow(2, 10)
hits = 0
process_time()
for i in range(1, DARTS):
x, y = random(), random()
dist = sqrt(x**2 + y**2)
if dist <= 1.0:
hits = hits + 1
pi = 4 * (hits/DARTS)
print("pi的值是 %s" % pi)
print("程序运行时间是 %-5.5ss" % process_time())
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/wengyk/Python_learning.git
[email protected]:wengyk/Python_learning.git
wengyk
Python_learning
Python_learning
master

搜索帮助