nerdexam
Python_Institute

PCAP-31-03 · Question #30

Which of the following lines of code will work flawlessly when put independently inside the add_new () method in order to make the snippet's output equal to [0, 1, 2]? (Select two answers)

The correct answer is A. self.queue.append(self.get_last() + 1) C. self.queue.append(self.queue[-1] + 1). See the full explanation below for the reasoning.

Question

Which of the following lines of code will work flawlessly when put independently inside the add_new () method in order to make the snippet's output equal to [0, 1, 2]? (Select two answers)

Exhibit

PCAP-31-03 question #30 exhibit

Options

  • Aself.queue.append(self.get_last() + 1)
  • Bself.queue.append(get_last() + 1)
  • Cself.queue.append(self.queue[-1] + 1)
  • Dqueue.append(self.get_last() + 1)

How the community answered

(24 responses)
  • A
    83% (20)
  • B
    13% (3)
  • D
    4% (1)

Community Discussion

No community discussion yet for this question.

Full PCAP-31-03 Practice