-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
53 lines (44 loc) · 1.11 KB
/
main.py
File metadata and controls
53 lines (44 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import numpy as np
class Point():
"""
A point in a 2D (xy) space
properties:
x: float, x-coordinate
y: float, y-coordinate
"""
def __init__(self, xy=None):
"""
Constructor
If xy is not provided, randomly generate xy coordiantes.
Otherwise, xy can be assigned by a tuple (e.g., (2, 3))
"""
# properties
self.x = None
self.y = None
# assign values to x and y
if xy is None:
pass
else:
pass
def __repr__(self):
"""
Allow the xy-coordinates to be printed when the point is called
"""
return "Point: %.2f, %.2f" % (self.x, self.y)
def distance(self, point):
"""
input: a Point() object
output: Euclidean distance between self point and the input point
"""
pass
def estimate_pi(n_points):
"""
input: number of points to be generated
output: estimated pi through the simulation
"""
pass
# estimate pi for 100 iterations
n_iter = 100
pi = np.zeros(n_iter)
for i in range(n_iter):
pass