200-901 Software Development and Design Practice Question
Which Python list comprehension correctly creates a list of squares for even numbers from 0 to 10?
⚠ Common exam trap
Cisco often tests the subtle difference between `range(10)` and `range(11)` to see if candidates remember that `range(n)` generates numbers from 0 to n-1, and also tests the distinction between `x % 2` (odd filter) and `x % 2 == 0` (even filter).
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
[x**2 for x in range(11) if x % 2 == 0]
It uses list comprehension syntax with `x**2` to square each number, iterates over `range(11)` to include numbers 0 through 10, and applies the condition `if x % 2 == 0` to filter only even numbers. This produces the list `[0, 4, 16, 36, 64, 100]` as required.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
[x**2 for x in range(11) if x % 2 == 0]
Why this is correct
The comprehension iterates x over range(11), covering 0 to 10 inclusive, and the filter x % 2 == 0 admits only even values before squaring with x**2. This satisfies both constraints in the stem: the even-number condition and the 0-to-10 bounds, producing 0, 4, 16, 36, 64, 100.
- ✗
[x*2 for x in range(11) if x % 2 == 0]
Why it's wrong here
Multiplying x by 2 doubles the value rather than squaring it, so the list holds 0, 4, 8, 12 rather than 0, 4, 16, 36. It is tempting because the range(11) bound and even filter are both right, and doubling superficially resembles exponentiation.
- ✗
[x**2 for x in range(10) if x % 2]
Why it's wrong here
range(10) excludes 10, and the filter if x % 2 keeps odd values, so the output is squares of 1, 3, 5, 7, 9. It is tempting because x**2 is the correct squaring operator and the comprehension structure is otherwise sound.
- ✗
[x**2 for x in range(10) if x % 2 == 0]
Why it's wrong here
range(10) stops before 10, so 100 is omitted; the stem requires 0 to 10 inclusive, needing range(11). It is tempting because the squaring operator and the even-number filter are both correct, leaving only the upper bound wrong.
Go deeper
Related to this question
About these practice questions
This 200-901 question is part of Courseiva's 975-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 200-901 practice question is part of Courseiva's free Cisco certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 200-901 exam.