import math
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def distance(self, other_point):
return math.sqrt(
(self.x - other_point.x) ** 2 +
(self.y - other_point.y) ** 2
)
def __str__(self):
return f"Point({self.x}, {self.y})"
p1 = Point(1, 2)
p2 = Point(4, 6)
print(p1)
print(p2)
print(p1.distance(p2))
To embed this project on your website, copy the following code and paste it into your website's HTML: