![]() | ![]() |
class ParentClass:
Body of parent class
class ChildClass(ParentClass):
Body of derived class
Example
Start IDLE.
Navigate to the File menu and click New Window.
Type the following:
class Rect_mine(Rect_mine):
def __init__(self):
Shape.__init__(self,4)
def getArea(self):
s1, s2, s3,s4 = self.count_sides
perimeter = (s1+s2+s3+s4)
area = (s1*s2)
print('The rectangle area is:' %area)
Example 2
r = rect_mine()
r.inputSides()
Type b1 : 4
Type l1 : 8
Type b2 : 4
Type l1: 8
r.dispSides()
Type b1 is 4.0
Type l1 is 8.0
Type b2 is 4.0
Type l1 is 8.0
r.getArea()