def __init__(selfx= = )self self def distance_from_origin(self)return math hypot(self xself ydef __eq__(selfother)return self =other and self =other def __repr__(self)return "point({ ! }{ ! })format(selfdef __str__(self)return "({ ! }{ ! })format(selfsince no base classes are specifiedpoint is direct subclass of objectjust as though we had written class point(objectbefore we discuss each of the methodslet' see some examples of their useimport shape shape point(repr(ab shape point( str(bb distance_from_origin( - str(ba =ba ! returns'point( )returns'( )returns returns'(- )returns(falsetruethe point class has two data attributesself and self yand five methods (not counting inherited methods)four of which are special methodsthey are illustrated in figure once the shape module is importedthe point class can be used like any other the data attributes can be accessed directly ( )and the class integrates nicely with all of python' other classes by providing support for the equality operator (==and for producing strings in representational and string forms and python is smart enough to supply the inequality operator (!=based on the equality operator (it is also possible to specify each operator individually if we want total controlfor exampleif they are not exact opposites of each other python automatically supplies the first argument in method calls--it is an object reference to the object itself (called this in +and javawe must include this argument in the parameter listand by convention the parameter is called self all object attributes (data and method attributesmust be qualified by self this requires little bit more typing compared with some other languagesbut has the advantage of providing absolute claritywe always know that we are accessing an object attribute if we qualify with self