import random
S = 1e6
N = 0
for i in range(int(S)):
x = random.random()
y = random.random()
d = (x-0.5)**2+(y-0.5)**2
if d<=0.5**2:
N+=1
else:
pass
PI = 4*N/S
print(PI)
print("3118")
标签:运算,int,random,0.5,range,1e6 From: https://www.cnblogs.com/ptptpt/p/17802521.html