import time
from random import random
from math import sqrt
from time import clock
DARTS=10000
hits=0.0
scale=10
clock()
print("-----执行开始------")
for i in range(1,scale+1):
a,b='**'*i,'..'*(scale-i)
c=(i/scale)*100
print("%{:^3.0f}[{}->{}]".format(c,a,b))
time.sleep(0.1)
for i in range(1,DARTS+1):
x,y=random(),random()
dist=sqrt(x**2+y**2)
if dist<=1.0:
hits=hits+1
pi=4*(hits/DARTS)
print("pi值是{}".format(pi))