Lecture Notes on 9 Sep 2020 def test_cases(): assert merge_tuples ([(1, 2)]) == [(1,2)] assert merge_tuples ([(1, 2), (3, 4)]) == [(1, 2), (3, 4)] assert merge_tuples ([(1, 2), (2, 4)]) == [(1, 4)] assert merge_tuples ([(1, 5), (2, 4)]) == [(1, 5)] assert merge_tuples ([(1, 3), (2, 4)]) == [(1, 4)] import math class Point (object): # constructor def __init__ (self, x = 0, y = 0): self.x = x self.y = y # get the distance to another Point object def dist (self, other): return math.hypot (self.x - other.x, self.y - other.y) # string representation of a Point def __str__ (self): return '(' + str(self.x) + ', ' + str(self.y) + ')' # test for equality of two Point objects def __eq__ (self, other): tol = 1.0e-6 return ((abs(self.x - other.x) < tol) and (abs(self.y - other.y) < tol)) def main(): # create Point objects a = Point (3, 4) b = Point (3, 4) # print the Point objects print (a) print (b) # get distances print (a.dist(b)) print (b.dist(a)) # test for equality print (a == b) main()