PCPP-32-101 · Question #57
Which of the following examples using line breaks and different indentation methods are compliant with PEP 8 recommendations? (Choose two.) A. B. C. D.
The correct answer is B. def my_function( var_one, var_two, var_three, var_four): pass D. def my_function(var_one, var_two): total = arg_a + arg_b # Four spaces for indentation. return total # Four spaces for indentation. Uses a hanging indent with four spaces for the continued argument lines, and the body is indented four spaces under the def, which matches PEP 8. Keeps the entire signature on one line and indents the body by four spaces, also compliant with
Question
Which of the following examples using line breaks and different indentation methods are compliant with PEP 8 recommendations? (Choose two.) A. B. C. D.
Exhibit
Options
- A
def foo(arg_a, arg_b): total = arg_a + arg_b # Four spaces for indentation. return total # One tab for indentation. - B
def my_function( var_one, var_two, var_three, var_four): pass - C
def my_function( var_one, var_two, var_three, var_four): pass - D
def my_function(var_one, var_two): total = arg_a + arg_b # Four spaces for indentation. return total # Four spaces for indentation.
How the community answered
(27 responses)- A7% (2)
- B89% (24)
- C4% (1)
Explanation
Uses a hanging indent with four spaces for the continued argument lines, and the body is indented four spaces under the def, which matches PEP 8. Keeps the entire signature on one line and indents the body by four spaces, also compliant with
Topics
Community Discussion
No community discussion yet for this question.
