- A
The config file key is misspelled; check spelling.
Why wrong: Incorrect: config is correctly parsed.
- B
The threshold is a string; convert it to float before comparison.
Correct: string vs float comparison is false.
- C
Use a try-except block to catch TypeError.
Why wrong: Incorrect: no TypeError occurs, just logical error.
- D
The load variable is a string; convert to float.
Why wrong: Incorrect: load is a float.
Quick Answer
The answer is that the comparison silently fails because the threshold is a string, not a float. In Python, comparing a float to a string with the greater-than operator does not perform numeric comparison; instead, Python 3 returns False for such mixed-type comparisons without raising an error, causing the alert to never trigger even when the load exceeds 0.85. This scenario tests your understanding of type coercion and comparison behavior, a common trap on the Certified Entry-Level Python Programmer PCEP exam where candidates must remember that configuration values read as text require explicit conversion. The fix is straightforward: convert the string to a float using `float(config['threshold'])` before the comparison. A useful memory tip is “strings sort, floats compare”—if you see a quote, convert it to a number before you compare.
PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
This PCEP practice question tests your understanding of data types, variables, basic i/o and operators. The scenario asks you to isolate a root cause — eliminate options that address a different problem before choosing. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.
A company runs a Python script on a server that monitors network traffic. The script reads a configuration file containing a threshold value as a string, e.g., '0.85'. The script compares this threshold to a calculated load average (float). The developer writes: threshold = config['threshold']; if load > threshold: alert(). The alert never triggers even when load exceeds 0.85. The config file is correctly parsed. What is the most likely cause and solution?
Clue words in this question
Noticing these words before you look at the options changes how you read each choice.
Clue:
"most likely"Why it matters: Probability qualifier — the question wants the most probable cause or outcome, not a guaranteed one. Eliminate low-probability options.
Clue:
"never"Why it matters: Absolute qualifier. True only if the statement has zero exceptions — be cautious of options that seem obvious but break down in edge cases.
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
The threshold is a string; convert it to float before comparison.
Option B is correct because the configuration file stores the threshold as a string ('0.85'), but the comparison operator (>) in Python compares strings lexicographically, not numerically. When load is a float (e.g., 0.9), comparing a float to a string always returns False in Python 3 (raising a TypeError in some contexts, but here the comparison silently fails because the string is not converted). The fix is to explicitly convert the threshold to a float using float(config['threshold']) before the comparison.
Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The config file key is misspelled; check spelling.
Why it's wrong here
Incorrect: config is correctly parsed.
- ✓
The threshold is a string; convert it to float before comparison.
Why this is correct
Correct: string vs float comparison is false.
Clue confirmation
The clue words "most likely", "never" in the question point toward this answer.
Related concept
Read the scenario before looking for a memorised answer.
- ✗
Use a try-except block to catch TypeError.
Why it's wrong here
Incorrect: no TypeError occurs, just logical error.
- ✗
The load variable is a string; convert to float.
Why it's wrong here
Incorrect: load is a float.
Common exam traps
Common exam trap: answer the scenario, not the keyword
Python Institute often tests the misconception that Python will automatically coerce a string to a number in comparisons, or that a TypeError will be raised, when in fact the comparison silently fails due to type mismatch.
Detailed technical explanation
How to think about this question
In Python, comparing a float to a string with > or < does not raise a TypeError in Python 3; instead, it returns a consistent but arbitrary result (e.g., False for any float vs. non-empty string) due to the underlying C implementation of rich comparisons. This behavior is a common pitfall when reading numeric values from configuration files, environment variables, or CSV files, where all data is initially parsed as strings. The correct approach is to always cast external numeric data to the appropriate type (int or float) before performing arithmetic or comparison operations.
KKey Concepts to Remember
- Read the scenario before looking for a memorised answer.
- Find the constraint that changes the correct option.
- Eliminate answers that are true in general but not in this case.
TExam Day Tips
- Watch for words such as best, first, most likely and least administrative effort.
- Review why wrong options are wrong, not only why the correct option is correct.
Key takeaway
Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Real-world example
How this comes up in practice
A practitioner preparing for the PCEP exam encounters this exact type of scenario on the job. The correct answer here is not the most general option — it is the best answer for the specific constraint described. Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option. Real exam questions reward reading the full scenario before eliminating options, because the constraint defines which answer fits.
What to study next
Got this wrong? Here's your next step.
Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.
- →
Data Types, Variables, Basic I/O and Operators — study guide chapter
Learn the concepts, then practise the questions
- →
Data Types, Variables, Basic I/O and Operators practice questions
Targeted practice on this topic area only
- →
All PCEP questions
510 questions across all exam domains
- →
Certified Entry-Level Python Programmer PCEP study guide
Full concept coverage aligned to exam objectives
- →
PCEP practice test guide
How to use practice tests most effectively before exam day
Related practice questions
Related PCEP practice-question pages
Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.
Computer Programming and Python Fundamentals practice questions
Practise PCEP questions linked to Computer Programming and Python Fundamentals.
Data Types, Variables, Basic I/O and Operators practice questions
Practise PCEP questions linked to Data Types, Variables, Basic I/O and Operators.
Control Flow, Loops, Lists and Logic practice questions
Practise PCEP questions linked to Control Flow, Loops, Lists and Logic.
Functions, Tuples, Dictionaries and Exceptions practice questions
Practise PCEP questions linked to Functions, Tuples, Dictionaries and Exceptions.
PCEP fundamentals practice questions
Practise PCEP questions linked to PCEP fundamentals.
PCEP scenario practice questions
Practise PCEP questions linked to PCEP scenario.
PCEP troubleshooting practice questions
Practise PCEP questions linked to PCEP troubleshooting.
Practice this exam
Start a free PCEP practice session
Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.
FAQ
Questions learners often ask
What does this PCEP question test?
Data Types, Variables, Basic I/O and Operators — This question tests Data Types, Variables, Basic I/O and Operators — Read the scenario before looking for a memorised answer..
What is the correct answer to this question?
The correct answer is: The threshold is a string; convert it to float before comparison. — Option B is correct because the configuration file stores the threshold as a string ('0.85'), but the comparison operator (>) in Python compares strings lexicographically, not numerically. When load is a float (e.g., 0.9), comparing a float to a string always returns False in Python 3 (raising a TypeError in some contexts, but here the comparison silently fails because the string is not converted). The fix is to explicitly convert the threshold to a float using float(config['threshold']) before the comparison.
What should I do if I get this PCEP question wrong?
Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.
Are there clue words in this question I should notice?
Yes — watch for: "most likely", "never". Probability qualifier — the question wants the most probable cause or outcome, not a guaranteed one. Eliminate low-probability options.
What is the key concept behind this question?
Read the scenario before looking for a memorised answer.
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 →
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.