Transcript
Use with ChatGPT / Claude Auto-scroll A
the following content is provided under a Creative Commons license your support will help MIT open courseware continue to offer highquality educational resources for free to make a donation or view additional materials from hundreds of MIT courses visit MITopencourseware at
ocw.mit.edu so we have a class car here object as as usual the init method here takes in self as usual a w and a d so uh so a car gets initialized with two uh parameters and we assignthe wheels data attribute to the first one and the do's data attribute to the second one and then we're going to also assign a color data attribute um to be the empty string so I'm giving you four choiceshere and the question says which of the above is a getter method for the number of Wheels okay so getter method is something that's going to get a data attribute a method is really just a function so ofcourse we're going to have DF get wheels is a good name for it since it's a method for this class we have to have self in the par parameters so we know it's going to be between c and
d and so then what are we going to return the first one is going to return Wheels which in this particular case is just going to be a variable that we haven't defined but it's a variable a getterreturn returns a data attribute of a particular instance so we actually have to say self dot if we want to return a data attribute of an instance as opposed to just a a regular variable so the correct answeris D great job