-
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.
In-Class Questions and Video Solutions
Lecture 9
Course Info
Instructors
Departments
As Taught In
Fall
2016
Level
Learning Resource Types
assignment
Problem Sets
notes
Lecture Notes
theaters
Lecture Videos
assignment_turned_in
Programming Assignments with Examples