PCEP-30-02 · Question #105
The expression: 'mike' > 'Mike' is
The correct answer is B. true. In Python, string comparison is lexicographic - it compares characters by their Unicode (ASCII) code points, not alphabetically in the human sense. Lowercase 'm' has ASCII value 109, while uppercase 'M' has value 77; since 109 > 77, the comparison resolves to True at the very…
Question
Options
- Aerroneous
- Btrue
- Cfalse
How the community answered
(52 responses)- A10% (5)
- B85% (44)
- C6% (3)
Explanation
In Python, string comparison is lexicographic - it compares characters by their Unicode (ASCII) code points, not alphabetically in the human sense. Lowercase 'm' has ASCII value 109, while uppercase 'M' has value 77; since 109 > 77, the comparison resolves to True at the very first character without examining the rest.
Why the distractors are wrong:
- A (erroneous) - String comparison with
>is perfectly valid Python syntax; no error is raised. - C (false) - This is the intuitive trap: humans think of "mike" and "Mike" as the same name, but Python doesn't - it sees raw numeric values, and lowercase always beats uppercase in ASCII.
Memory tip: Think "lowercase = lower on the keyboard, but higher in ASCII." All lowercase letters (97–122) come after all uppercase letters (65–90) in the ASCII table, so any lowercase letter will always be greater than any uppercase letter when compared directly.
Community Discussion
No community discussion yet for this question.