LearnPy Hub
← Inheritance & Special Methods problems
Hard

Square Is a Rectangle

Rectangle has width, height, area() and resize(w, h). Square(Rectangle) takes one side and overrides resize(w, h=None) so that both sides always become w. Read commands until END: rect w h or square s create the shape, resize a b resizes it, area prints the area.

Input

Commands, then END.

Output

Lines.

Sample 1

Input
rect 2 3
area
resize 4 5
area
END
Output
6
20

Sample 2

Input
square 3
area
resize 5 9
area
END
Output
9
25
solution.py
Output appears here
Square Is a Rectangle · Python practice problem · LearnPy Hub