Open this example in the interactive library
Source code
class Rectangle:
def __init__(self, width, height):
self.width, self.height = width, height
@property
def area(self):
return self.width * self.height
print(Rectangle(3, 4).area)Sample output
12
