Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- N = 30
- tk = 4;
- for i range(0,N):
- x = random.random()
- y = random.random()
- if(x*x + y*y <1):
- tk = tk+1
- print("pi =", tk)
- pi = 4*tk/N
- print("pi =", pi)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement