码迷,mamicode.com
首页 > 其他好文 > 详细

有进度条圆周率计算

时间:2020-03-29 19:56:11      阅读:72      评论:0      收藏:0      [点我收藏+]

标签:执行   开始   center   结束   family   16px   code   art   img   

有进度条圆周率计算:

代码:

 

import math
import time
scale=14
s = 1
m = 2
print("执行开始".center(scale//2, "-"))
start = time.perf_counter()
for i in range(scale+1):
    s=math.sqrt((1-math.sqrt(1-pow(s,2)))/2)
    m=m*2
    a = * * i
    b = . * (scale - i)
    c = (i/scale)*100
    dur = time.perf_counter() - start
    print("\r{:^3.0f}%[{}->{}]{:.2f}s".format(c,a,b,dur))
time.sleep(0.1)
Pi=s*m
print("Pi值是{}".format(Pi))
print("\n"+"执行结束".center(scale//2,-))

 

输出:

技术图片

 

有进度条圆周率计算

标签:执行   开始   center   结束   family   16px   code   art   img   

原文地址:https://www.cnblogs.com/linantelope/p/12593995.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!