Compute area and update dimensions
Input
r = Rectangle(3, 4) r.area
Output
12
Area is computed as 3 * 4 = 12. If width or height change, area will reflect the new values.
Full lesson preview
Create a Rectangle class with width and height and a read-only computed area property.
Problem statement
Task
Examples
Input
r = Rectangle(3, 4) r.area
Output
12
Area is computed as 3 * 4 = 12. If width or height change, area will reflect the new values.
Input format
Output format
Constraints
Samples
Input
Rectangle(2.5, 3).area
Output
7.5
Area computed with float inputs yields a float result.