一 计算公式:
二 实现代码
(1)
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)
(2)
import time
import math
class Index(object):
def __init__(self, number=50, decimal=2):
self.decimal = decimal
self.number = number
self.a = 100/number
def __call__(self, now, total):</