Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Воспользуемся методом Монте-Карло
- import random
- num_point_total = 10000000
- num_point_circle = 0
- for i in range(num_point_total):
- x = random.uniform(0, 1)
- y = random.uniform(0, 1)
- distance = x**2 + y**2
- if distance <= 1:
- num_point_circle += 1
- print(4 * num_point_circle/num_point_total)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement