Question: Q 2 : Create a class Box that has attributes length and width that takes values for length and width upon construction ( instantiation via
Q: Create a class Box that has attributes length and width that takes values for length
and width upon construction instantiation via the constructor
In addition, create...
A method called render that prints out to the screen a box made with asterisks of
length and width dimensions
A method called invert that switches length and width with each other
Methods getarea and getperimeter that return appropriate geometric calculations
A method called double that doubles the size of the box. Hint: Pay attention to return
value here.
Implement eq so that two boxes can be compared using Two boxes are equal if
their respective lengths and widths are identical.
A method printdim that prints to screen the length and width details of the box
A method getdim that returns a tuple containing the length and width of the box
A method combine that takes another box as an argument and increases the length
and width by the dimensions of the box passed in
A method gethypot that finds the length of the diagonal that cuts through the middle
Instantiate boxes of dimensions and and assign to variables box
box and box respectively
Print dimension info for each using printdim
Evaluate if box box and also evaluate if box box print True or False to the
screen accordingly
Combine box into boxie boxcombine
Double the size of box
Combine box into box
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
