from turtle import *
import random
tracer(False)
bgpic("dot.png")
setup(1200,800)
t=Pen()
t.ht()
t.penup()
nei=0
total=0
t2=Pen()
t2.ht()
t2.penup()
t2.goto(380,-50)
while 1:
x=random.randint(-200,200)
y=random.randint(-200,200)
t.goto(x,y)
if t.distance(0,0)<200:
t.dot(5,'yellow')
nei+=1
else:
t.dot(5,'magenta')
total+=1
pai=4*nei/total
t2.clear()
t2.write("{}\n\n{}\n\n{}".format(nei,total,round(pai,4)),font=("宋体",25,'bold'))
update()