Exam-style question
Try this first
What is the result of the Python set comprehension {2 * x for x in {1, 2, 3}}?.
- A.{1, 2, 3}
- B.{2, 3, 4}
- C.{2, 4, 6}
- D.{1, 4, 9}
Model answer
What a good answer should say
- {2, 4, 6}
Explanation
Why this works
The comprehension multiplies each element of {1, 2, 3} by 2. The resulting values are 2, 4 and 6.
Common mistake
No common mistake is linked to this question yet.
