Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def compute_pi_throwing_dart(n_throws):
- """
- Computes pi by throwing a bunch of darts at the square
- """
- n_throws = n_throws
- count_inside_circle=0
- for i in range(n_throws):
- r1,r2=throw_dart()
- if is_within_circle(r1,r2):
- count_inside_circle+=1
- result = 4*(count_inside_circle/n_throws)
- return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement