PCEP-30-02 · Question #124
Which of the following variable names is illegal?
The correct answer is D. In_. There appears to be an error in this question as presented. Looking at the four choices - In, IN, in_, and In_ - all four are valid Python identifiers. None of them match in, which is the actual Python reserved keyword. The question is almost certainly testing knowledge of…
Question
Options
- AIn
- BIN
- Cin_
- DIn_
How the community answered
(33 responses)- A9% (3)
- B3% (1)
- C3% (1)
- D85% (28)
Explanation
There appears to be an error in this question as presented. Looking at the four choices - In, IN, in_, and In_ - all four are valid Python identifiers. None of them match in, which is the actual Python reserved keyword.
The question is almost certainly testing knowledge of Python's in keyword, but has a labeling issue. Here is the explanation for what the question is likely intending:
Python's in keyword (lowercase, no modifications) is a reserved word used for membership testing and iteration - it cannot be used as a variable name. In (choice A) and IN (choice B) are valid because Python is case-sensitive and neither matches the keyword exactly. in_ (choice C) is valid because the trailing underscore makes it a distinct identifier from the keyword. The memory tip: Python keywords are always lowercase - capitalizing or appending an underscore to a keyword turns it into a legal identifier.
If this came from a textbook or course platform, I'd recommend checking the original source - the choices may have been scrambled or incorrectly transcribed, causing the answer key (D) to point to In_ rather than the intended in. The concept being tested is sound; the labeling appears to be the problem.
Community Discussion
No community discussion yet for this question.