draak

导航

有进度条圆周率计算

 1 import math
 2 import time 
 3 scale=14
 4 s,m,=1,2
 5 print("执行开始".center(scale//2, "-"))
 6 start = time.perf_counter()
 7 for i in range(scale+1): 
 8     s=math.sqrt((1-math.sqrt(1-pow(s,2)))/2)
 9     m=m*2
10     a = "*"* i 
11     b = '.' * (scale - i)
12     c = (i/scale)*100 
13     dur = time.perf_counter() - start 
14     print("\r{:^3.0f}%[{}->{}]{:.2f}s".format(c,a,b,dur))
15 time.sleep(0.1)
16 Pi=s*m
17 print("Pi值是{}".format(Pi))
18 print("\n"+"执行结束".center(scale//2,'-'))
有进度条圆周率计算代码

 

posted on 2020-03-21 11:26  c-pig  阅读(199)  评论(0编辑  收藏  举报