# Functions

Reply

Reply

import random print ("Let's calculate Pi\n") c=0 maxx=1000 for l in range(1,maxx): # print ("We're generating point %d" % (l)) x = random.uniform(0,1) y = random.uniform(0,1) # print ("(" + str(x) + "," + str(y) + ")",end="\n") r = x*x + y*y # print ("r = " + str(r)) if r < 1: # print ("In the circle",end="\n") c+=1 p = float(c)*4/float(l) print ("Pi estimate after " + str(maxx) + " iterations = " + str(p) + "\n")