Advertisement
Guest User

1

a guest
Feb 27th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.20 KB | None | 0 0
  1. import random
  2. N = 30
  3. tk = 4;
  4.  
  5. for i range(0,N):
  6. x = random.random()
  7. y = random.random()
  8. if(x*x + y*y <1):
  9. tk = tk+1
  10.  
  11. print("pi =", tk)
  12. pi = 4*tk/N
  13. print("pi =", pi)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement