1. Home
  2. Data Science
  3. Python
  4. What is the output of the following Python code snippet?

Added 25 Nov 2026

What is the output of the following Python code snippet?

from collections import deque
d = deque([1, 2, 3])
d.rotate(1)
print(d)
  1. deque([1, 2, 3])
  2. deque([3, 1, 2]) Correct answer
  3. [3, 1, 2]
  4. deque([2, 3, 1])

Correct answer

B. deque([3, 1, 2])

6 views

MCQSEXAM

Explanation

rotate(1) moves the rightmost element to the left end.

Reference

Asked in: Python Interview Advanced

https://docs.python.org/3/library/index.html

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs