nerdexam
Python_Institute

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

Which of the following variable names are illegal? (Choose two.)

Options

  • ATrue
  • Btrue
  • Cand
  • DTRUE

How the community answered

(63 responses)
  • A
    70% (44)
  • B
    17% (11)
  • C
    10% (6)
  • D
    3% (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, so true (lowercase) is not a keyword and is a valid identifier.
  • D (TRUE) is legal for the same reason - all-caps TRUE is not a reserved word in Python, only True (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.

Full PCEP-30-02 Practice