标签:算法 number code 计算 str 进度 圆周率 utf-8 alt
用python算圆周率
1.准备第三方库pip

3.用python语言编写出求圆周率到任意位的程序如下:
from math import *
from tqdm import tqdm
from time import *
total,s,n,t=0.0,1,1.0,1.0 clock()
while(fabs(t)>=1e-6):
total+=t n+=2 s=-s t=s/n k=total*4 print("π值是{:.10f}
运行时间为{:.4f}秒".format(k,clock())) for i in tqdm(range(101)): print("\r{:3}%".format(i),end="") sleep((clock())/100)#用执行程序的总时间来算出进度条间隔的时间
标签:算法 number code 计算 str 进度 圆周率 utf-8 alt
原文地址:https://www.cnblogs.com/wxyzzj/p/10575536.html