Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# import the math and random modules # sets seed to input num = int ( input ( ) ) random.seed ( num ) hits

# import the math and random modules
# sets seed to input
num = int(input())
random.seed(num)
hits =0
for i in range(10000):
theta = # randomly generate an angle from 0 to 180 degrees
D = # randomly generate a number from 0 to 0.5
if : # write condition for the needle hitting the line before the :
hits +=1
approximation = # write formula for the approximation of pi
print(f'{approximation:.6f}')9.7 LAB: Buffon's needle
Write a computer program that finds an approximation for pi using the Buffon's needle simulation as described in the animation and
participation activity. The program should take in an input value for the seed and output the approximation for pi.
If the input for the seed is:
123
Then the output should be:
3.178134
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions