This project will give you practice with looping and if/else statements. You will use a technique called Monte Carlo simulation to approximate the number pi. The basically approach is that you throw a large number of "darts" at a dartboard, and seeing how many actually hit it.
Write a Python program (call it 'pi.py') by completing the following:
monte(darts)that takes a number of darts as a parameter. The darts parameter represents how many darts you want to throw at an imaginary dart board.
monte(darts)so that it approximates the value pi by repeatedly throwing random virtual darts that land at points with x and y coordinates in the range shown in the image below. Thus, both x and y should be a random number that land in the square. Count the number that land at points within distance 1 of the origin (think distance formula), and return this fraction.
Your program output will vary due to the use of random numbers, but your output should look similar to the following:
Monte Carlo Simulator for Approximating PI How many darts do you want to throw: 1000 The approximated value of pi is this_number_will_vary.
To submit, save your Python program in a file named 'pi.py', and submit it to Moodle by the due date.