1 2 3 4 5 6 7 8 9
import random import math count_inside = 0 for count in range(0, 10000): d = math.hypot(random.random(), random.random()) if d < 1: count_inside += 1 count += 1 print 4.0 * count_inside / count
1
3.1536