Skip to content

Commit 1457bc9

Browse files
committed
Update point.py
1 parent 5a4a5da commit 1457bc9

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

point.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import math
2+
3+
class Point2D:
4+
def __init__(self, x, y):
5+
self.x = x
6+
self.y = y
7+
8+
def distance_to(self, other):
9+
dx = self.x - other.x
10+
dy = self.y - other.y
11+
return math.sqrt(dx * dx + dy * dy)
12+
13+
def __str__(self):
14+
return f"Point2D({self.x}, {self.y})"

0 commit comments

Comments
 (0)