代码如下 def PI(n): pi=0 for k in range(n): pi += 1/pow(16,k)*(4/(8*k+1)-2/(8*k+4)-1/(8*k+5)-1/(8*k+6)) return piimport timescale = 20print("执行开始".center(scale+4,'-'))for i in range(scale+1): a='*' * i b='.' * (scale-i) c=(i/sca
代码如下
def PI(n): pi=0 for k in range(n): pi += 1/pow(16,k)*(4/(8*k+1)-2/(8*k+4)-1/(8*k+5)-1/(8*k+6)) return pi import time scale = 20 print("执行开始".center(scale+4,'-')) for i in range(scale+1): a='*' * i b='.' * (scale-i) c=(i/scale)*100 pi = PI(1000) print("{:^3.0f}%[{}->{}]".format(c,a,b)) time.sleep(0.1) print("圆周率值是:{}".format(pi)) print("执行结束".center(scale+4,'-'))
结果如下
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持易盾网络。