from math import * class Point: def __init__(self,initialX=10,initialY=20): self._x=initialX self._y=initialY def getX(self): return self._x def getY(self): return self._y def setX(self,val): self._x=val def setY(self,val): self._y=val def move(self,dx,dy): self._x +=dx self._y +=dy def distance(self,other): dx=self._x-other._x dy=self._y-other._y return sqrt(dx*dx+dy*dy) def __str__(self): return '('+str(self._x)+','+str(self._y)+')' def main(): p1=Point(30,40) p2=Point(40,60) print "Two points created so far, with coordinates", print '(',p1.getX(),',', p1.getY(), ')', 'and (', p2.getX(),',',p2.getY(),').' p1.move(10,20) p2.move(30,10) print 'Points were moved and their new coordinates are:', print '(',p1.getX(),',', p1.getY(), ')', 'and (', p2.getX(),',',p2.getY(),').' print 'The distance between these points is:',p1.distance(p2) main()