Question: Python please 5.28 Programming Project 1: Buffon Needle Experiment The Buffon Needle Experiment was devised by Comte Georges-Louis Leclerc de Buffon (1707 -- 1788), a

Python please 5.28 Programming Project 1: Buffon Needle Experiment The Buffon NeedlePython please

5.28 Programming Project 1: Buffon Needle Experiment The Buffon Needle Experiment was devised by Comte Georges-Louis Leclerc de Buffon (1707 -- 1788), a French naturalist. In this experiment a 1 inch long needle is repeatedly dropped onto paper that is ruled with lines 2 inches apart. Any dropped needle crossing a line counts as a hit. Buffon discovered the quotient of drops/hits to be a very significant quantity. In this assignment, you will simulate this experiment to make the same discovery. To simulate an drop, we must imagine how to specify whether or not a needle dropped randomly will cross a line. The random placement of the needle must be specified by two quantities: 1. The location of the lower end of the needle x, between 0 and 2 inches. 2. The angle the needle makes with respect to the ruled lines e, between 0 and it radians. From those two numbers, one can easily calculate the the location of the upper end of the needle xy (apply your knowledge of trigonometry to do this). If xu is greater than 2 inches, the needle crosses the line. The figure below shows both a "missed" attempt (left) and a "hit" (right). Each is the result of randomly selecting x, and e. Note that we think of the needle as simply a thin rigid rod of unit length; the designation of "lower" end just refers to the end that is located closest to 0, and the other end is then designated the "upper" end. Also, we only need to consider the interval between 0 and 2 inches, although in actuality Buffon used a target with many ruled lines separated by two inches. This is just because we lose no information by "translating" every drop to a reference frame between 0 and 2 inches. The code template below is a program my_Buffon.py that partially defines a function called do_Buffon (). It's first argument is N, the number of drops to make. Its second argument is a seed, an integer that seeds the pseudorandom number generator. Note that in the body of do_Buffon() is the statement seed(a_seed) that you should not alter. do_Buffon () must evaluate a_quantity as the quotient of number of drops over number of hits, which the function returns via the statement return a_quantity. If there are no hits at all, assign 0 to a_quantity rather than trying to calculate it. Complete the body of this function definition. The __main__code block provided in the template enables you to test this program locally on your own computer before you upload your solution. You may put anything you like in the main_block; only your do_Buffon() function will be evaluated for a grade. As a final hint, notice that the program also imports the function random() from the random module. random(), if called with no argument, returns a random floating point between 0.0 and 1.0. 5.28 Programming Project 1: Buffon Needle Experiment The Buffon Needle Experiment was devised by Comte Georges-Louis Leclerc de Buffon (1707 -- 1788), a French naturalist. In this experiment a 1 inch long needle is repeatedly dropped onto paper that is ruled with lines 2 inches apart. Any dropped needle crossing a line counts as a hit. Buffon discovered the quotient of drops/hits to be a very significant quantity. In this assignment, you will simulate this experiment to make the same discovery. To simulate an drop, we must imagine how to specify whether or not a needle dropped randomly will cross a line. The random placement of the needle must be specified by two quantities: 1. The location of the lower end of the needle x, between 0 and 2 inches. 2. The angle the needle makes with respect to the ruled lines e, between 0 and it radians. From those two numbers, one can easily calculate the the location of the upper end of the needle xy (apply your knowledge of trigonometry to do this). If xu is greater than 2 inches, the needle crosses the line. The figure below shows both a "missed" attempt (left) and a "hit" (right). Each is the result of randomly selecting x, and e. Note that we think of the needle as simply a thin rigid rod of unit length; the designation of "lower" end just refers to the end that is located closest to 0, and the other end is then designated the "upper" end. Also, we only need to consider the interval between 0 and 2 inches, although in actuality Buffon used a target with many ruled lines separated by two inches. This is just because we lose no information by "translating" every drop to a reference frame between 0 and 2 inches. The code template below is a program my_Buffon.py that partially defines a function called do_Buffon (). It's first argument is N, the number of drops to make. Its second argument is a seed, an integer that seeds the pseudorandom number generator. Note that in the body of do_Buffon() is the statement seed(a_seed) that you should not alter. do_Buffon () must evaluate a_quantity as the quotient of number of drops over number of hits, which the function returns via the statement return a_quantity. If there are no hits at all, assign 0 to a_quantity rather than trying to calculate it. Complete the body of this function definition. The __main__code block provided in the template enables you to test this program locally on your own computer before you upload your solution. You may put anything you like in the main_block; only your do_Buffon() function will be evaluated for a grade. As a final hint, notice that the program also imports the function random() from the random module. random(), if called with no argument, returns a random floating point between 0.0 and 1.0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!