1. Home
  2. Data Science
  3. Python
  4. What will be the result of [x for x in range(5)] in Python?

Added 4 May 2024

What will be the result of [x for x in range(5)] in Python?

  1. [0, 1, 2, 3, 4] Correct answer
  2. [1, 2, 3, 4, 5]
  3. [1, 2, 3, 4]
  4. [0, 1, 2, 3]

Correct answer

A. [0, 1, 2, 3, 4]

14 views

MCQSEXAM

Explanation

List comprehension generates a list containing numbers from 0 to 4.

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