Lecture Notes on 23 Jan 2013 import math class Point (object): # constructor def __init__ (self, x = 0, y = 0): self.x = x self.y = y # get distance def dist (self, p): return math.hypot (self.x - p.x, self.y - p.y) # string representation def __str__ (self): return '(' + str(self.x) + ', ' + str(self.y) + ')' class Circle (object): # constructor def __init__ (self, radius = 0.0): self.radius = radius # public radius # compute circumference def circumference (self): return 2.0 * math.pi * self.radius # compute area def area (self): return math.pi * self.radius * self.radius # string representation def __str__(self): return 'Radius = ' + str(self.radius) # test for equality def __eq__ (self, c): return (abs(self.radius - c.radius) < 1.0e-16) def main(): # create an object circleA = Circle () circleB = Circle (2.3) # change radius circleA.radius = 1.2 # get radius print (circleA.radius) # compute area print (circleB.area()) # print Cirlce print (circleB) # test if two circles are equal print (circleA == circleB) main()