1. Home
  2. Data Science
  3. Python
  4. Which of the following statements is used to create a list…

Added 27 Jan 2024

Which of the following statements is used to create a list in Python?

  1. list = {1, 2, 3}
  2. list = (1, 2, 3)
  3. list = [1, 2, 3] Correct answer
  4. list = "1, 2, 3"

Correct answer

C. list = [1, 2, 3]

16 views

MCQSEXAM

Explanation

list = [1, 2, 3] creates a list — square brackets define lists in Python.

Curly braces {1, 2, 3} create a set, parentheses (1, 2, 3) a tuple, and quotes a string. (In real code avoid naming a variable list, because that hides the built-in type.)

Practise more Computer Science MCQs with answers and explanations on MCQsExam.com.

Doubts & discussion

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