Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You have been asked to create a program in Python that will calculate the cost y

ID: 3856831 • Letter: Y

Question

You have been asked to create a program in Python that will calculate the cost you will need to charge to install a laminate floor. You have decided to write a class that will determine the rate you will charge and the total area, including waste, that you will need to install the flooring in a room. Your program will ask the user for the length and width of the room before it creates an object based on the class. Which of the following is the class constructor?

A.) def __init__(self, NewLength, NewWidth):

B.) def __init__(self):

C.) LaminateFloor(NewLength, NewWidth)

D.) class LaminateFloor(NewLength, NewWidth)

Explanation / Answer

A) def __init__(self, NewLength, NewWidth):

The self parameter refers to the instance of the object.

The __init__ method will gets called when memory for the object is allocated

NewLength and NewWdith will be stored in a stack and get discarded when init method goes out of scope.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote