PCEP Control Flow, Loops, Lists and Logic Practice Question
A data analyst has a list named readings containing numeric sensor values. She needs to build a new list that contains only the values strictly greater than 10, preserving their original order. Which code fragment produces this result?
⚠ Common exam trap
Test-takers frequently confuse the expression position with the condition position in a comprehension, which turns a filter into a list of Boolean results.
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
✓
filtered = [x for x in readings if x > 10]
A filtering list comprehension keeps only the elements that satisfy the condition and preserves their original order. Writing the element expression as x and placing the comparison after if yields the desired numeric values. Using an inclusive comparison admits boundary values, putting the comparison itself in the expression yields Booleans, and appending a reverse slice destroys the original ordering.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
filtered = [x for x in readings if x >= 10]
Why it's wrong here
The condition x >= 10 includes values equal to 10, but the requirement is strictly greater than 10. A reading of exactly 10 would be wrongly retained in the output, producing a list that does not match the stated filter. The rest of the comprehension is correct, so the failure is entirely due to the boundary comparison being inclusive instead of exclusive.
- ✓
filtered = [x for x in readings if x > 10]
Why this is correct
This list comprehension iterates over readings in order, keeps each element only when x > 10, and collects the survivors into a new list. Because iteration follows the original sequence, the relative order of the kept values is preserved. It also leaves the original readings list unchanged, which matches the analyst's need to derive a filtered list rather than modify the source data.
- ✗
filtered = [x > 10 for x in readings]
Why it's wrong here
This comprehension evaluates the comparison for every element but places the Boolean result in the new list instead of the element itself. The output would be a list of True and False values, not the numeric readings. To keep the values, the expression before for must be x, with the condition placed after if, as in a proper filtering comprehension.
- ✗
filtered = [x for x in readings if x > 10][::-1]
Why it's wrong here
The filtering part is correct, but slicing with [::-1] reverses the resulting list. The analyst explicitly wants to preserve the original order of the readings. Reversing might be useful in other contexts, yet here it silently changes the sequence so that the first qualifying reading appears last, which does not satisfy the scenario's ordering requirement.
Go deeper
Related to this question
About these practice questions
This PCEP question is part of Courseiva's 482-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 and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Python Institute exam blueprint
This PCEP practice question is part of Courseiva's free Python Institute 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 PCEP exam.