Question: Define a new-style class Rectangle, whose instances have attributes width and height, both expected to be numbers. When Rectangle() is called, it is passed values

 Define a new-style class Rectangle, whose instances have attributes width and

Define a new-style class Rectangle, whose instances have attributes width and height, both expected to be numbers. When Rectangle() is called, it is passed values for both these attributes. When an instance of Rectangle appears where a string is expected, it returns a string of the form (width) * Sheight) rectangle", where width) is the value of selt width and height) is the value of self height; both values should be formatted to have one digit after the decimal point and to occupy as much space as needed. An instance of Rectangle has a method area () that returns the product of its width and height attributes Next, define a class ScalableRectangle that inherits from Rectangle, adding only the method scale(), which, passed a number, updates the width and The following is test code in the file where both these classes are defined in our solution. i na 1 - Rectangle(4.0, 2.0) print("A (0) with area (1:10)". formattel, El (3) BrSealablalactangle(5.0, 3.0) print("A (0) with area (1:1)"format (st. Are ( RELA (2.0) print (0) with area (111) formatie, er area) The following is the output produced A 4.0 x 2.0 rectangle with 8.0 A 50. rectangle with 15.0 A 10.0 6.0 eutangle with are 50.0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!