20+ practice questions focused on Functions, Tuples, Dictionaries and Exceptions — one of the most tested topics on the Certified Entry-Level Python Programmer PCEP exam. Each question includes a detailed explanation so you learn why the right answer is correct.
Start Functions, Tuples, Dictionaries and Exceptions PracticeA developer writes a function to calculate the average of a list of numbers, but the function sometimes returns a wrong result when the list contains non-numeric values. What is the best way to handle this?
Explanation: Option D is correct because it explicitly validates that all items are numeric before performing the calculation, raising a TypeError if any non-numeric value is found. This follows Python's principle of explicit error handling and ensures the function's contract is clear: it only works with numeric data. Returning None (A) or silently ignoring values (B) can lead to subtle bugs, while converting to strings (C) would produce a concatenated string, not an average.
A Python script uses a dictionary to store user session data. The developer writes `user = {'id': 101, 'name': 'Alice'}` and later tries to access `user['email']`. What is the outcome?
Explanation: In Python, accessing a dictionary key that does not exist raises a KeyError. The dictionary `user` contains only the keys 'id' and 'name', so `user['email']` triggers a KeyError because the key 'email' is not present. This is a fundamental behavior of Python dictionaries, which do not return default values for missing keys unless a method like `.get()` is used.
A server logs are stored as a list of tuples: `logs = [('2024-01-10', 'INFO', 'Started'), ('2024-01-10', 'ERROR', 'Disk full')]`. A developer wants to count how many ERROR logs exist. Which code snippet correctly counts them?
Explanation: Option B uses a generator expression with `sum()` to count how many tuples in the `logs` list have the second element equal to `'ERROR'`. The expression `log[1] == 'ERROR'` evaluates to `True` (which is treated as 1) or `False` (0) for each tuple, and `sum()` adds them up, giving the correct count of ERROR logs.
A function `def process(data):` modifies the dictionary passed as argument by adding a new key. The developer wants to avoid modifying the original dictionary. What should the function do?
Explanation: Option A is correct because dictionaries are mutable objects in Python, so passing a dictionary to a function passes a reference to the same object. Calling `data.copy()` creates a shallow copy of the dictionary, allowing the function to modify the copy without affecting the original dictionary. This is the standard Pythonic way to avoid side effects on mutable arguments.
A developer writes a function that returns multiple values as a tuple. Which of the following is a valid way to unpack the result into separate variables?
Explanation: Option D is correct because when a function returns multiple values as a tuple, Python allows tuple unpacking directly in an assignment statement. The syntax `a, b = func()` automatically unpacks the two-element tuple into the variables `a` and `b`, which is the standard and most Pythonic way to handle such a return.
+15 more Functions, Tuples, Dictionaries and Exceptions questions available
Practice all Functions, Tuples, Dictionaries and Exceptions questions1. Baseline your knowledge
Start with 10 questions to gauge your current understanding of Functions, Tuples, Dictionaries and Exceptions. This tells you whether you need a concept refresher or just practice.
2. Review every explanation
For each question — right or wrong — read the full explanation. Understanding why an answer is correct is more valuable than knowing the answer itself.
3. Focus on exam traps
Functions, Tuples, Dictionaries and Exceptions questions on the PCEP frequently use trap wording. Look for subtle differences in answers that test your precision, not just general knowledge.
4. Reach 80% consistently
Do repeated sessions until you score 80%+ three times in a row. Then move to mixed-mode practice to test cross-topic recall under realistic conditions.
The exact number varies per candidate. Functions, Tuples, Dictionaries and Exceptions is tested as part of the Certified Entry-Level Python Programmer PCEP blueprint. Practicing with targeted Functions, Tuples, Dictionaries and Exceptions questions ensures you can handle any format or difficulty that appears.
Yes. Courseiva provides free PCEP practice questions across all exam topics and domains. The platform includes topic-based practice, mock exams, missed-question review, bookmarked questions, and readiness tracking — no account required.
Difficulty is subjective, but Functions, Tuples, Dictionaries and Exceptions is a high-priority exam concept tested in multiple ways — direct recall, scenario analysis, and command-output interpretation. Consistent practice is the best way to build confidence.
Launch a full Functions, Tuples, Dictionaries and Exceptions practice session with instant scoring and detailed explanations.
Start Functions, Tuples, Dictionaries and Exceptions Practice →