Python Institute PCEP sample questions with explanations, traps, topic labels, and IT Mastery route links.
These original sample questions are designed to help you check how the exam topics appear in decision-style prompts. They are not taken from the live exam.
Use these sample questions as a guided self-assessment for Certified Entry-Level Python Programmer (PCEP) topics such as variables, types, operators, control flow, loops, functions, scope, exceptions, strings, lists, tuples, dictionaries, and basic object concepts. The prompts focus on tracing execution accurately.
The sample set below is part of the Python Institute PCEP guide path:
Work through each prompt before opening the explanation. PCEP questions often test exact values, types, scope, mutation, and exceptions rather than broad definitions.
Topic: List mutation versus rebinding
What is printed by this code?
1items = [1, 2]
2alias = items
3items += [3]
4items = items + [4]
5print(alias)
[1, 2][1, 2, 3][1, 2, 3, 4]TypeError.Best answer: B
Explanation: alias and items initially refer to the same list. items += [3] mutates that list in place. Then items = items + [4] creates a new list and rebinds items, leaving alias pointing to the list that contains [1, 2, 3].
Why the other choices are weaker:
+=.alias.What this tests: Object identity, list mutation, and variable rebinding.
Related topics: Lists; Mutation; Aliasing; Rebinding
Topic: Loop else behavior
What is printed by this code?
1for n in [2, 4, 6]:
2 if n % 2:
3 print("odd")
4 break
5else:
6 print("done")
oddodd and then donedoneBest answer: C
Explanation: The if condition is false for every even number, so the loop never executes break. A loop else block runs when the loop completes normally.
Why the other choices are weaker:
break.else block.What this tests: Loop completion, break, truthiness of modulo results, and loop else.
Related topics: Loops; else; break; Modulo
Topic: Default argument state
What is printed by this code?
1def add(value, bucket=[]):
2 bucket.append(value)
3 return bucket
4
5print(add(1))
6print(add(2))
[1] and then [2][] and then [][1] and then [1, 2]Best answer: D
Explanation: Default argument objects are created when the function is defined, not each time it is called. Both calls use the same list because no second argument is supplied.
Why the other choices are weaker:
append mutates the list.What this tests: Function defaults, list mutation, and call-time versus definition-time behavior.
Related topics: Functions; Default arguments; Lists; State
Topic: Dictionary lookup and exceptions
What is printed by this code?
1data = {"a": 1, "b": 2}
2try:
3 print(data["c"])
4except KeyError:
5 print(data.get("c", 0))
0NoneKeyError1Best answer: A
Explanation: Indexing a missing key with data["c"] raises KeyError. The handler then uses get("c", 0), which returns the provided default value 0.
Why the other choices are weaker:
data.get("c") without an explicit default."a", not key "c".What this tests: Dictionary indexing, get, default values, and exception handling flow.
Related topics: Dictionaries; KeyError; get; Exceptions
Tech Exam Lexicon and IT Mastery are independent study tools. They are not affiliated with, endorsed by, or sponsored by Python Institute or any certification body.