1. Add read-only properties
Write code Easy ✓ CompletedThe class Rectangle stores width and height. Add two read-only properties: area (width times height) and perimeter (2 times width plus height). They are read without parentheses, for example room.area.
class Rectangle:
def __init__(self, width, height):
self.width = width
self.height = height
# add the area and perimeter properties here
room = Rectangle(4, 5)
print(room.width, room.height)@property on the line above def area(self): and return self.width * self.height. Do the same for perimeter.class Rectangle:
def __init__(self, width, height):
self.width = width
self.height = height
@property
def area(self):
return self.width * self.height
@property
def perimeter(self):
return 2 * (self.width + self.height)
room = Rectangle(4, 5)
print(room.area, room.perimeter)