python 求π的程序
作者:互联网
求π的程序
import random
import math
paosha=1000000
yuan=0.0
for i in range(paosha+1):
a=random.random()
b=random.random()
c=math.sqrt(a2+b2)
if c<=1.0:
yuan=yuan+1
pi = 4*(yuan/paosha)
print(pi)
标签:yuan,python,random,程序,paosha,import,pi,math 来源: https://blog.csdn.net/qq_40168905/article/details/121955798