计算圆周率

import math

from tqdm import tqdm
import time
total,s,n,t=0.0,1,1.0,1.0
while(math.fabs(t)>=1e-6):
    total+=t
    n+=2
    s=-s
    t=s/n
k=total*4
print("π值是{:.10f}  运行时间为{:.4f}秒".format(k,time.clock()))
for i in tqdm(range(101)):
    print("\r{:3}%".format(i),end="")
    time.sleep(0.1)
posted @ 2020-10-19 19:11  达尔文的第三人称  阅读(73)  评论(0编辑  收藏  举报