nerdexam
Python_Institute

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.

PEP and Best Practices

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)
  • A
    93% (38)
  • C
    2% (1)
  • D
    5% (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

#PEP 8#naming conventions#snake_case#CamelCase

Community Discussion

No community discussion yet for this question.

Full PCPP-32-101 Practice