#CalPi.py
from random import random
from math import sqrt
from time import clock
DARTS = 10000000
hits = 0.0
clock()
for i in range(1, DARTS+1):
x, y = random(), random()
dist = sqrt(x ** 2 + y ** 2)
if dist <= 1.0:
hits = hits + 1
pi = 4.0 * (hits/DARTS)
print("pi值是{}".format(pi))
print("运行时间是:{:5.5}s".format(clock()))

最新文章

  1. CrashMonkey4IOS App测试
  2. 媒体查询使用方法@media
  3. [QDB] 幽灵分享:QDataSet+TQMSSQLConverter 实战技巧
  4. mysql之旅【第一篇】
  5. Delphi ActiveX Form的使用实例
  6. CnPlugin 1.5.400
  7. Cross Site Request Forgery (CSRF)--spring security -转
  8. css3图片滤镜
  9. 在fragment中获取他附着的activity中的变量
  10. POJ 2392 Space Elevator 背包题解
  11. 继承Object和ContextBoundObject处理效率上的差距
  12. 【Maven】运行项目,报ClassNotFound错误
  13. 树莓派安装ftp服务器
  14. 编译搭建Lamp服务器
  15. javascript里的几种常见的数组方法
  16. 开发环境中Docker的使用
  17. virualbox 虚拟机管理
  18. python random 随机选择操作
  19. 使用putty进行ssh tunnel远程内网机器
  20. TestNG+Excel+(HTTP+JSON) 简单接口测试

热门文章

  1. 启动ZOOKEEPER之后能查看到进程存在但是查不到状态,是因为。。。
  2. 点击按钮时,显示不同的div内容
  3. ElasticSearch基本概念阐述
  4. 实验查看PHP本地的Session信息
  5. TCP窗口
  6. Codeforces Round #340 (Div. 2) E. XOR and Favorite Number (莫队)
  7. 2019hdu多校3 hdu4893(线段树单点 区间更新
  8. [POI2007]POW-The Flood(并查集)
  9. JS大文件上传解决方案
  10. 特权第一讲--Lesson 1 课程概述与如何学好FPGA