1. Home
  2. Data Science
  3. Python
  4. In Python, which data structure is used to implement a…

Added 25 Jan 2024

In Python, which data structure is used to implement a queue?

  1. List Correct answer
  2. Tuple
  3. Queue
  4. Dictionary

Correct answer

A. List

19 views

MCQSEXAM

Explanation

Among the built-in types listed, a list is used to implement a queue: add with append() and remove from the front with pop(0).

Because pop(0) is slow on long lists, collections.deque is the recommended choice in real code, and the queue module offers thread-safe queues — but neither is a basic built-in data structure.

Keep preparing with more Computer Science MCQs on MCQsExam.com.

Doubts & discussion

Not sure why the answer is A? 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