QuestionQ81

VerifiedObject-Oriented Programming

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

Question Image

Choose two
Explanation

self.queue is the instance list, initially [0, 1]. Its last value is 1, so appending that value plus 1 adds 2. Both direct instance-list access and the instance method call through self correctly access that value.

Community Discussion

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