Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Please Need help to solve this question using Python Programming Language, and I have attach help for question that i found. 5.28 LAB: Buffon needle

Please Need help to solve this question using Python Programming Language, and I have attach help for question that i found.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

5.28 LAB: 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 dropped onto paper that is ruled with lines 2 inches apart. If the needle drops onto a line, we count it as a hit. Buffon discovered the quotient of attempts/hits to be a very significant quantity. In this exercise, you will simulate this experiment to make the same discovery The link to the full description of the lab is here LAB 528.1 LAB Buffon needle experiment 0/15 ACTIVITY main.py Load default template... 1 from math import pi, sin from random import random, seed 4 seed(2019) # Seeding the random number generator. Do not change this value 6 trials int (input()) # Number of trials to perform 8 # FIXME: each time through a trial 9 # Calculate y-low as a random floating point value between 0 and 2.0. 10 # Calculate the angle theta as a random floating point value between 0 and pi, in radians 11 # Calculate y-high 12 # Determine if we have a hit; if so keep count of the hits L: 14 # Print trials/hits as a floating-point value{ 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 dropped onto paper that is ruled with lines 2 inches apart. If the needle drops onto a line, we count it as a hit. Buffon discovered the quotient of attempts/hits to be a very significant quantity. In this exercise, you will simulate this experiment to make the same discovery. To simulate the Buffon needle experiment, you will need to generate two random numbers: one random number to describe where the tail of the needle landed on the y-axis and another to describe the angle of the needle with respect to the x-axis. A random floating point number between O and 1.0 can be generated using the function random(), which you need to import from the Python module also named random. So, at the top of your python program you will need the following code: from random import random Which says to import the function random) from the random module. You could then, for example, generate a random number between 0 and 100 with the following code: from random import random some float_between_0 and_100 100.0*random) print some.float.between 0-and.100 For this experiment, you may generate the coordinate of where the tail of the needle landed ytail as a number between 0 and 2.0. Likewise, the angle the needle makes with respect to the x-axis will randomly be something between 0 and radians. The head of the needle yhead may then be computed as: head ytail +sin(0) than 2.0, you count that simulated attempt as a hit. Vhead is greater Likewise, if yhead is less than 2.0, do not count that attempt as a hit. ail 0 The trigonometric function sin) is available from the math module, as is the numerical constant T. You can import these for use in your program by adding the following statement to the top of your Python program from math import pi, sin # Some simple demonstration print pi print sin(pi/2.0) Your program should prompt the user for the number of attempts to perform (i.e. how many times we will simulate dropping the needle) and print the ratio attempts/hits as a floating point number after all the attempts have completed. Note that if hits 0, that is, if none of the trials succeeded in dropping the needle across the line, then output Hint: This can be achieved in about 20 lines of code.) Now validate your simulation results by performing the physical experiment

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions