from random import random from time import perf_counter pi = 0 N = 100 start = perf_counter() 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)) print('公式法:') print("圆周率值是{}".format(pi)) print("运行时间是: {:.5f}s".format(perf_counter()-start))
标签:counter,perf,python,random,print,pi From: https://www.cnblogs.com/FXY-/p/17801992.html