Question 446 of 498
PCEP Control Flow, Loops, Lists and Logic Practice Question
Exhibit
Refer to the exhibit.
data = [{'name': 'Alice', 'age': 30}, {'name': 'Bob', 'age': 25}]
for person in data:
if person['age'] >= 26:
print(person['name'])
elif person['age'] < 20:
print('Too young')
else:
print('Check')What is the output of the code?
⚠ Common exam trap
Python Institute often tests the understanding that a loop's body may not execute for all elements, and that code after the loop always runs, leading candidates to incorrectly include or exclude the final print statement.
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
✓
Alice Check
The code iterates over the list `['Alice', 'Bob']`. For each name, if the length is less than 5, the loop continues to the next iteration without printing. 'Alice' has length 5, so the condition is false and 'Alice' is printed. 'Bob' has length 3, so the condition is true and the loop skips printing 'Bob'. After the loop ends, `print('Check')` executes, printing 'Check'. Therefore, the output is 'Alice' followed by 'Check' on separate lines. Option A correctly shows this.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Alice Check
Why this is correct
Correct. The code prints 'Alice' and then 'Check'.
- ✗
Alice
Why it's wrong here
Incorrect. The output is not just 'Alice'; 'Check' is printed after the loop.
- ✗
Alice Too young
Why it's wrong here
Incorrect. 'Too young' is not printed by this code.
- ✗
Alice Bob
Why it's wrong here
Incorrect. 'Bob' is not printed because the `continue` skips it.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on PCEP
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. Given a list of names = ['Alice', 'Bob', 'Charlie'], a developer wants to create a dictionary mapping each name to its length. Which expression accomplishes this?
easy- A.{len(name): name for name in names}
- ✓ B.{name: len(name) for name in names}
- C.{name: len for name in names}
- D.{name: length for name in names}
Why B: It uses a dictionary comprehension that iterates over each name in the list, using the name as the key and the result of `len(name)` as the value. This directly maps each name to its length, which is exactly what the developer wants.
Last reviewed: Jun 30, 2026
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.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.