PCEP-30-02 · Question #167
isainum() checks if a string contains only letters and digits, and this is:
The correct answer is C. A method. isalnum() (note the correct spelling) is a string method because it belongs to Python's built-in str class and is called directly on a string object - e.g., "abc123".isalnum() - using dot notation. It is not a module (option A), since modules are importable packages like math…
Question
Options
- AA module
- BA function
- CA method
How the community answered
(39 responses)- A13% (5)
- B8% (3)
- C79% (31)
Explanation
isalnum() (note the correct spelling) is a string method because it belongs to Python's built-in str class and is called directly on a string object - e.g., "abc123".isalnum() - using dot notation. It is not a module (option A), since modules are importable packages like math or os that group related functionality together. It is not a standalone function (option B) either, because functions are called independently - like len("abc") - rather than being owned by an object. A helpful memory tip: if you call it with a dot on a string ("text".isalnum()), it's a method; methods always belong to an object, while functions stand alone.
Community Discussion
No community discussion yet for this question.