from random import * from kandinsky import * def dot(x,y,c): xp=round(180*x+65) yp=round(180*(1-y)+10) set_pixel(xp,yp,c) def pi(n): h=0 for i in range(n): x=random() y=random() if x*x+y*y<1: h+=1 dot(x,y,color(0,255,0)) else: dot(x,y,color(255,0,0)) return 4*h/n def pi_graphics(): n=int(input("How many darts: ")) black=(0,0,0) gray=(234,234,234) fill_rect(64,9,182,182,black) fill_rect(65,10,180,180,color(255,255,255)) d="Darts: "+str(n) p="pi: "+str(pi(n)) draw_string(d,10,200) draw_string(p,170,200)