class Rectangle object def __init__ self self self property def perime

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
class Rectangle(object):
def __init__(self, a, b):
self.a = a
self.b = b
@property
def perimeter(self):
return 2 * (self.a + self.b)
class Square(Rectangle):
def __init__(self, a):
super(Square, self).__init__(a, a)
if __name__ == '__main__':
rec = Rectangle(1, 2)
print rec.perimeter
sq = Square(2)
print sq.perimeter