Question PRG-PY-0006
EasyWhat is the output of this program?
print([x * x for x in range(4)])
- A.
[0, 1, 2, 3]
- B.
[1, 4, 9, 16]
- C.
Show answer and explanation
Answer: D
The list comprehension squares each number from 0 to 3.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Python question
What is the output of this program?
print([x * x for x in range(4)])
[0, 1, 2, 3]
[1, 4, 9, 16]
Answer: D
The list comprehension squares each number from 0 to 3.
[0, 2, 4, 6]
[0, 1, 4, 9]