What is the sum of the squared values?
print(sum(x * x for x in [1, 2]))Answer & explanation
Answer: 5
The comprehension squares each input and sum adds the results.
Practice comprehensions with self-contained questions. Check your answer, then use the explanation to understand the reasoning.
print(sum(x * x for x in [1, 2]))Answer: 5
The comprehension squares each input and sum adds the results.