QuestionQ61

VerifiedObject-Oriented Programming

Which of the following code lines will work correctly when independently placed inside the add_new() method so that the snippet outputs [0, 1, 1]?

Question Image

Choose two
Explanation

At that point, the stored list is [0, 1]. Both self.store[1] and self.get()[-1] evaluate to 1, and passing either value to self.put(...) appends it to the list. Names such as store and put must be accessed through self inside an instance method.

Community Discussion

No comments yet. Be the first to start the discussion!