KnowledgeBoat Logo

Computer Science

Suppose list1 = [0.5 * x for x in range(0, 4)], list1 is:

  1. [0, 1, 2, 3]
  2. [0, 1, 2, 3, 4]
  3. [0.0, 0.5, 1.0, 1.5]
  4. [0.0, 0.5, 1.0, 1.5, 2.0]

Python List Manipulation

1 Like

Answer

[0.0, 0.5, 1.0, 1.5]

Reason — The list comprehension [0.5 * x for x in range(0, 4)] generates a list by calculating 0.5 * x for each value of x in the range from 0 to 3 (not including 4), which results in the list [0.0, 0.5, 1.0, 1.5].

Answered By

1 Like


Related Questions