zoukankan      html  css  js  c++  java
  • 有进度条的圆周率计算

    #JDTYZL.py
    import math
    import time
    scale=14
    s,m,=1,2
    print("执行开始".center(scale//2, "-"))
    start = time.perf_counter()
    for i in range(scale+1):
    s=math.sqrt((1-math.sqrt(1-pow(s,2)))/2)
    m=m*2
    a = '*' * i
    b = '.' * (scale - i)
    c = (i/scale)*100
    dur = time.perf_counter() - start
    print(" {:^3.0f}%[{}->{}]{:.2f}s".format(c,a,b,dur))
    time.sleep(0.1)
    Pi=s*m
    print("Pi值是{}".format(Pi))
    print(" "+"执行结束".center(scale//2,'-'))

    执行结果:

    ================= RESTART: C:/Users/86139/Desktop/寒假/进度条圆周率.py =================
    --执行开始-
    0 %[->..............]0.00s
    7 %[*->.............]0.18s
    14 %[**->............]0.40s
    21 %[***->...........]0.59s
    29 %[****->..........]0.78s
    36 %[*****->.........]0.98s
    43 %[******->........]1.17s
    50 %[*******->.......]1.30s
    57 %[********->......]1.51s
    64 %[*********->.....]1.76s
    71 %[**********->....]1.96s
    79 %[***********->...]2.14s
    86 %[************->..]2.36s
    93 %[*************->.]2.55s
    100%[**************->]2.73s
    Pi值是3.1415926453212153

  • 相关阅读:
    python os
    [BZOJ2887] 旅行
    UVA1104 Chips Challenge
    CF364E Empty Rectangles
    CF1408H Rainbow Triples
    CF1214G Feeling Good
    CF506E Mr. Kitayuta's Gift
    采用Canal监听mysql数据库变化
    Java8 ParallelStream
    Java8 方法引用
  • 原文地址:https://www.cnblogs.com/567823a/p/12548233.html
Copyright © 2011-2022 走看看