PCEP-30-02 · Question #122
Which of the following variable names are illegal? (Choose two.)
The correct answer is A. True. True is a reserved keyword in Python - it represents the boolean literal and cannot be used as a variable name. Similarly, and is a reserved keyword (a logical operator), making it equally illegal; this appears to be a "choose two" question where both A and C are correct. Why…
Question
Options
- ATrue
- Btrue
- Cand
- DTRUE
How the community answered
(63 responses)- A70% (44)
- B17% (11)
- C10% (6)
- D3% (2)
Explanation
True is a reserved keyword in Python - it represents the boolean literal and cannot be used as a variable name. Similarly, and is a reserved keyword (a logical operator), making it equally illegal; this appears to be a "choose two" question where both A and C are correct.
Why the distractors are wrong:
- B (
true) is legal - Python is case-sensitive, sotrue(lowercase) is not a keyword and is a valid identifier. - D (
TRUE) is legal for the same reason - all-capsTRUEis not a reserved word in Python, onlyTrue(title case) is.
Memory tip: Python's reserved keywords match their exact casing in the language spec - True, False, None, and, or, not, etc. If you can use it in a boolean expression or it appears in the keyword module (import keyword; keyword.kwlist), it's off-limits as a variable name. When in doubt, remember that Python's boolean literals are title-case (True/False), not all-lower or all-upper.
Community Discussion
No community discussion yet for this question.