Professional Documents
Culture Documents
Def Main
Def Main
perimeter print "" print "Rectangle b:" b = Rectangle() b.width = 10 b.height = 20 print b.getStats()
From this main function, which I should not change, I am supposed to get this as an expected output:
When the Rectangle class has been properly created, the output should look like the following:
Rectangle a: area: 35 perimeter: 24 Rectangle b: width: 10 height: 20 area: 200 perimeter: 60
This is the Code Ive built, but it doesnt work class rectangle: def __init__(self, Rectangle = 'b'): self._Rectangle = Rectangle
return width
def main(): print "Rectangle a:" a = Rectangle(5, 7) print "area: %d" % a.area
print "" print "Rectangle b:" b = Rectangle() b.width = 10 b.height = 20 print b.getStats()
def set_Width(self, width): if (width <= 0): print "Width must be larger than 0." print "Setting width to 10." self.width = 10 else: self.width = width
def setHeight(self, height): if (height <=0): print "Height must be larger than 0." print "Setting height to 20" self.height = 20 else: self.height = height
def getStats(): print "width" print "height" print "perimeter: ((width*2)+(height*2))" print "area: (width*height)"
def main():
print "" print "Rectangle b:" b = Rectangle() b.width = 10 b.height = 20 print b.getStats()