Fraction of points lying outside the semicircle - Numpy(problem solution)

Sir, the excercise was to find out the fraction of points lying outside the semicircle, in this instead of creating a matrix of 100,000×2, I used a while loop initialized with 100000 and then called that function again n again… Is it right to do this way.

Yes this approach is also fine, can you share the snippet for more descriptive feedback

Sure sir,
I=100000
Count=0
While(I! =0) :
Points=np.random.rand((1, 2))
Points=points*points
Points=np.sum(points)
If np. Sqrt(points) >1:
Count+=1
Output count/I

1 Like

Sir this while loop is going to generate the numbers in every cycle