🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: The collections Module: all 10 questions

Quiz: The collections Module · Question 5 of 10

What does this print? (code)

What does this print?

from collections import deque
d = deque([1, 2, 3], maxlen=3)
d.append(4)
print(list(d))
  1. A.[1, 2, 3, 4]
  2. B.[1, 2, 3]
  3. C.[2, 3, 4]
  4. D.An error
Answer & explanation

Correct answer: [2, 3, 4]

A full deque drops an item from the opposite end when you add.

Can you get the rest right without peeking?

Take the timed Quiz: The collections Module quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →