import math
class Point:
def __init__( self, xValue = 0, yValue = 0 ):
self.x = xValue
self.y = yValue
class Circle( Point ):
def __init__( self, x = 0, y = 0, radiusValue = 0.0 ):
Point.__init__( self, x, y ) # call base-class constructor
self.radius = float( radiusValue )
def area( self ):
return math.pi * self.radius ** 2
circle = Circle( 37, 43, 2.5 ) # create Circle object
print "X coordinate is:", circle.x
print "Y coordinate is:", circle.y
print "Radius is:", circle.radius
circle.radius = 4.25
circle.x = 2
circle.y = 2
print circle
print "area: %.2f" % circle.area()
|