Computing Π progress bar with text

# Formula: [pi] / . 4 = . 1 - . 1 / . 3 + . 1 / . 5 - . 1 / . 7 + ....... 
Import Math 
Import Time 
scale = accurate reading of the scale 100 # Π size, the greater the more accurate . 
S, m, = . 1 , 2 
Total, S, n-, T = 0.0 , . 1 , 1.0 , 1.0 
Print ( " execution start " .center (Scale // 2, "-")) 
Start = time.perf_counter ()
 for i in range(scale+1): 
    total+=t
    n+=2 
    s=-s
    t=s/n
    k=total*4
    a = '*' * i 
    b = '.' * (scale - i)
    c = (i/scale)*100 
    dur = time.perf_counter() - start 
    print("\r{:^3.0f}%[{}->{}]{:.2f}s".format(c,a,b,dur))
time.sleep(0.1)
Pi= K 
Print ( " Pi value} { " .format (Pi)) 
Print ( " \ n- " + " execution finished " .center (Scale // 2, '-'))

Guess you like

Origin www.cnblogs.com/qq1294/p/12520151.html