-
Getters and Setters
Which of the below is a getter method for the number of wheels?
---------------------------------- ----------- Given ------------ ---------------------------------- class Car(object): def __init__(self, w, d): self.wheels = w self.doors = d self.color = "" ---------------------------------- (A) def get_wheels(): return wheels (B) def get_wheels(): return self.wheels (C) def get_wheels(self): return wheels (D) def get_wheels(self): return self.wheels
Subclass
What line could replace
____blank____
to create a class that inherits fromAnimal
in the code below?____blank____ def speak(self): print("ruff ruff") (line1) d = Dog(7) (line2) d.set_name("Ruffles") (line3) d.speak()
With this definition of Dog, you run a program with line1, line2, and line3 above. What happens? Refer to the lecture slides for the code making up the “Animal” class.
Course Info
Instructors
Departments
As Taught In
Fall 2016Level
Learning Resource Types
assignment Problem Setsnotes Lecture Notestheaters Lecture Videosassignment_turned_in Programming Assignments with Examples
In-Class Questions and Video Solutions
Lecture 9
MIT Open Learning
Over 2,500 courses & materials
Freely sharing knowledge with learners and educators around the world. Learn more
© 2001–2025 Massachusetts Institute of Technology
Proud member of:
Open Education Global
© 2001–2025 Massachusetts Institute of Technology