Certified Professional in Python Programming (PCPP-32-101) — Question 7
Select the true statements related to PEP 8 naming conventions. (Choose two.)
Answer options
- 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 argument to class methods.
- C. Modules should have short names written in CamelCase.
- D. Constants should be written in all lower-case letters with words separated by underscores.
Correct answer: A, B
Explanation
Option A is correct because PEP 8 specifies that function and variable names should be in lower-case with underscores. Option B is also correct as it emphasizes the use of 'self' and 'cls' as the first arguments for instance and class methods, respectively. Option C is incorrect because module names should be in all lower-case, not CamelCase. Option D is wrong since constants should be in all uppercase letters, not lower-case.