Lecture Notes on 25 Jan 2017 import math class Point (object): # constructor def __init__ (self, x = 0, y = 0): self.x = x self.y = y # get distance def dist (self, other): return math.hypot (self.x - other.x, self.y - other.y) # get a string representation of Point def __str__ (self): return '(' + str(self.x) + ", " + str(self.y) + ")" # test for equality def __eq__ (self, other): tol = 1.0e-16 return ((abs (self.x - other.x) < tol) and (abs(self.y - other.y) < tol)) def main(): # create Point objects pointA = Point () pointB = Point (3, 4) # print the coordinates of the points print (pointA) print (pointB) # find the distance between the points print (pointA.dist(pointB)) print (pointB.dist(pointA)) main()