nerdexam
Python_Institute

PCPP-32-101 · Question #22

Look at the following code snippets and decide which ones follow PEP 8 recommendations for whitespaces in expressions and statements. (Choose two.)

The correct answer is A. No whitespace immediately before the opening parenthesis that starts the list of arguments of a C. No whitespace between a trailing comma and a following closing parenthesis. PEP 8 recommends avoiding extraneous whitespace immediately inside parentheses, brackets or PEP 8 recommends avoiding extraneous whitespace between a trailing comma and a following close parenthesis 1.

PEP and Best Practices

Question

Look at the following code snippets and decide which ones follow PEP 8 recommendations for whitespaces in expressions and statements. (Choose two.)

Exhibits

PCPP-32-101 question #22 exhibit 1
PCPP-32-101 question #22 exhibit 2

Options

  • ANo whitespace immediately before the opening parenthesis that starts the list of arguments of a
  • BA whitespace immediately before a comma, semicolon, and colon
  • CNo whitespace between a trailing comma and a following closing parenthesis
  • DA whitespace immediately after the opening parenthesis that starts indexing or slicing

How the community answered

(55 responses)
  • A
    95% (52)
  • B
    4% (2)
  • D
    2% (1)

Explanation

PEP 8 recommends avoiding extraneous whitespace immediately inside parentheses, brackets or PEP 8 recommends avoiding extraneous whitespace between a trailing comma and a following close parenthesis 1.

Topics

#PEP 8#whitespace rules#expressions#statements

Community Discussion

No community discussion yet for this question.

Full PCPP-32-101 Practice