Courseiva

PCEP Practice Question: Data Types, Variables, Basic I/O and Operators

A developer is reviewing operators in Python. Which TWO of the following statements about comparison and logical operators are correct? (Choose two.)

⚠ Common exam trap

The trap here is assuming logical operators always produce True or False and that comparison chains behave like sequential boolean comparisons.

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 expression 3 < 5 < 8 is evaluated as (3 < 5) and (5 < 8).

Python evaluates chained comparisons as a series of and-ed comparisons, evaluating the middle operand once, and its logical operators return operands rather than forcing booleans while short-circuiting. Recognizing these two behaviors explains idioms like range checks and default-value fallbacks. The other statements misstate case sensitivity of strings, short-circuit evaluation of or, and the truthiness of zero.

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 expression 'a' == 'A' evaluates to True because comparisons ignore case.

    Why it's wrong here

    Python string comparisons are case-sensitive by default, using the Unicode code points of each character. The lowercase a and uppercase A have different code points, so 'a' == 'A' evaluates to False. To compare without regard to case, both strings must be normalized, for example by calling lower on each before comparing, which this expression does not do.

  • ✓

    The expression 3 < 5 < 8 is evaluated as (3 < 5) and (5 < 8).

    Why this is correct

    Python supports chained comparisons, so 3 < 5 < 8 is treated as a conjunction of two comparisons rather than evaluating 3 < 5 to a boolean and then comparing that boolean with 8. The middle operand 5 is evaluated only once. Both parts are true, so the whole expression is true, and this chaining feature makes range checks more concise and readable.

  • ✗

    The or operator always evaluates both of its operands before returning a result.

    Why it's wrong here

    The or operator short-circuits: if the left operand is truthy, it is returned immediately and the right operand is never evaluated. This matters when the right side has side effects, such as a function call. Writing condition = True or expensive_check() skips expensive_check entirely, so claiming both operands are always evaluated is incorrect for Python's behavior.

  • ✓

    The and operator returns the first operand if it is falsy, otherwise the second operand.

    Why this is correct

    Unlike some languages that always return a boolean, Python's and returns one of its operands. If the left operand is falsy, that value is returned without evaluating the right side; otherwise the right operand is returned. This short-circuit behavior allows idioms such as value = user_input or 'default', where a falsy input falls back to the default string.

  • ✗

    The expression not 0 evaluates to False because 0 is a number.

    Why it's wrong here

    The not operator applies logical negation to the truthiness of its operand. The integer 0 is falsy, so not 0 yields True, not False. Numeric zero, empty strings, empty containers, and None are all falsy in Python, while nonzero numbers and nonempty containers are truthy. This option misstates the result of negating a falsy value.

About these practice questions

One of 482 original PCEP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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.