0

Lets try this guys😊..for me ,am stuck😣

1. The value of pi can be calculated numerically in many ways. One approach is to use the “dartboard” method. This involves randomly “throwing darts” at a square with (x,y) extent of +/-1, and considering the fraction of darts which lie within a circle of radius 1 (the dartboard). Follow the steps given below to estimate the value of pi using the “dartboard” method (10mks) a. Import the math and random modules. (1mk) b. Set a value for the number of darts to be used. (e.g. ndarts = 1000). (1mk) c. For each dart, calculate a random (x,y) coordinate uniformly distributed within the range (-1,1), using the random.uniform() function. (1mks) d. Write a function called isInTheCircle() which takes the (x,y) coords of the dart, and returns True if the dart lies within the dartboard (a circle of radius 1), and False otherwise. (3mks) e. Loop, over the number of darts thrown, keeping track of the total number of times the dart hits the dartboard (nhit). (3mks)

17th Feb 2021, 8:28 PM
Samson Riika
Samson Riika - avatar
1 Respuesta
+ 3
Can you link your attempt? Which point can't you solve?
17th Feb 2021, 8:55 PM
Angelo
Angelo - avatar