SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top