Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. def compute_pi_throwing_dart(n_throws):
  2. """
  3. Computes pi by throwing a bunch of darts at the square
  4. """
  5. n_throws = n_throws
  6. count_inside_circle=0
  7. for i in range(n_throws):
  8. r1,r2=throw_dart()
  9. if is_within_circle(r1,r2):
  10. count_inside_circle+=1
  11.  
  12. result = 4*(count_inside_circle/n_throws)
  13.  
  14. return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement