Все задачи на 5.10.17 13:00
This commit is contained in:
13
uts/session_py/9.py
Normal file
13
uts/session_py/9.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from random import *
|
||||
|
||||
from math import cos, pi
|
||||
|
||||
n = 10000
|
||||
k = 0
|
||||
for i in range(n):
|
||||
y = uniform(-1, 1)
|
||||
x = uniform(-pi, pi)
|
||||
if ((y <= cos(x)) and (x >= -pi) and (x <= pi) and (y >= 0)) \
|
||||
or ((y >= cos(x)) and (x >= -pi) and (x <= pi) and (y <= 0)):
|
||||
k += 1
|
||||
print(k/n*pi*4)
|
||||
Reference in New Issue
Block a user