如何用python计算圆周率?


当前第2页 返回上一页

1

2

3

4

5

6

7

8

9

10

11

# pi.py

from random import random

from math import sqrt

from time import clock

DARTS = 1200

hits = 0 clock()

if dist <= 1.0:

hits = hits + 1

pi = 4 * (hits/DARTS)

print("Pi的值是 %s" % pi)

print("程序运行时间是 %-5.5ss" % clock())

推荐教程:《python》

以上就是如何用python计算圆周率?的详细内容,更多文章请关注木庄网络博客!!

返回前面的内容

相关阅读 >>

Python入门教程之列表操作

Python集合有序吗

Python怎么删除字符

Python如何判断数据类型

Python yield和yield from用法总结详解

Python怎么升序和降序排序

如何用Python画爱心

Python 怎么调用百度地图api

Python统计字符串中数字个数

Python基础教程项目三之万能的xml

更多相关阅读请进入《Python》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...