Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download
Views: 13
Visibility: Unlisted (only visible to those who know the link)
Image: ubuntu1804
Kernel: SageMath (system-wide)
import numpy as np import matplotlib.pyplot as plt circle = plt.Circle((0, 0), 1, color='r',clip_on=False, fill=False) N = 100 x = np.random.uniform(-1,1,N) y = np.random.uniform(-1,1,N) fig, graph = plt.subplots() plt.scatter(x, y) graph.add_artist(circle) graph.set_aspect(1) plt.show()
m=0 for k in range(N): if x[k]**2+y[k]**2<1: m+=1 print(m)
7799
p=float(4*(m/N)) print(p)
3.1196