PRACTICE / UNDERSTAND / REPEAT

Python practice question

Practice comprehensions with self-contained questions. Check your answer, then use the explanation to understand the reasoning.

1 questionAnswers explainedFree · no login

Try this question

Comprehensions · MCQQuestion link ↗

What is the sum of the squared values?

print(sum(x * x for x in [1, 2]))
Choose one answer
Answer & explanation

Answer: 5

The comprehension squares each input and sum adds the results.