import random,math try_count = 100000 hit_count = 0 for i in xrange(try_count): if (math.sqrt( random.random()**2 + random.random()**2 ) < 1) : hit_count+=1 print 4.0 * float(hit_count)/float(try_count);