Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

<< [14] Monte-Carlo estimate of Pi >>

The area of a circle is defined as πr². Estimate π to 3 decimal places using a Monte Carlo method.

Example:

>>> import math
>>> import random
>>> random.seed(0xBEEF)
>>> pi_approx = coding_problem_14()
>>> abs(math.pi - pi_approx) < 1e-2
True