Name_________________ net-id _______ Name_________________ net-id _______ Name_________________ net-id _______ Name_________________ net-id _______
16/7 + 16%3
The function point below is part of the snarfable
code in the Pydev project spring12-pistuff. Questions follow
the code.
def point(n):
inside = 0;
plt.axis('scaled')
plt.axis([0,1.1,0,1.1])
for dummy in range(n):
x = random.random()
y = random.random()
if x*x + y*y <= 1.0:
inside += 1
plt.plot(x,y,'ro')
else:
plt.plot(x,y,'bo')
return inside
inside?
inside initialized to zero before
the loop rather than within the loop body?
.plot and .axis?
(more than one possible)