PCPP-32-101 · Question #20
Select the true statements related to PEP 8 naming conventions. (Choose two.)
The correct answer is A. Function and variable names should be lower-case with words separated by underscores. B. You should always use self as the first argument to instance methods, and cls as the first. PEP 8 recommends using lower-case with words separated by underscores for function and variable names (e.g., 'function_name', 'variable_name'). PEP 8 recommends using self for instance methods and 'cls' for class methods.
Question
Select the true statements related to PEP 8 naming conventions. (Choose two.)
Options
- AFunction and variable names should be lower-case with words separated by underscores.
- BYou should always use self as the first argument to instance methods, and cls as the first
- CModules should have short names written in CamelCase.
- DConstants should be written in all lower-case letters with words separated by underscores.
How the community answered
(41 responses)- A93% (38)
- C2% (1)
- D5% (2)
Explanation
PEP 8 recommends using lower-case with words separated by underscores for function and variable names (e.g., 'function_name', 'variable_name'). PEP 8 recommends using self for instance methods and 'cls' for class methods.
Topics
Community Discussion
No community discussion yet for this question.