What will be the output of the following list comprehension?

print([x*x for x in range(1, 4)])
                        

Options

  • A. [1, 2, 3]
  • B. [1, 4, 9]
  • C. [1, 4, 6]
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. [1, 4, 9]

Detailed Explanation

Explanation: The squares of 1, 2 and 3 are 1, 4 and 9.