nerdexam
Python_Institute

PCPP-32-101 · Question #19

Select the true statements related to PEP 8 programming recommendations for code writing. (Choose two.)

The correct answer is B. You should make object type comparisons using the isinstance() method (e.g. if isinstance(obj , D. You should not write string literals that rely on significant trailing whitespaces, as they may be. Option B is true because PEP 8 recommends making object type comparisons using the isinstance() method instead of comparing types directly 1. Option D is true because PEP 8 recommends not writing string literals that rely on significant trailing whitespaces as they may be…

PEP and Best Practices

Question

Select the true statements related to PEP 8 programming recommendations for code writing. (Choose two.)

Options

  • AYou should use the not ... is operator (e.g. if not spam is None:), rather than the is not operator
  • BYou should make object type comparisons using the isinstance() method (e.g. if isinstance(obj ,
  • CYou should write code in a way that favors the CPython implementation over PyPy, Cython, and
  • DYou should not write string literals that rely on significant trailing whitespaces, as they may be

How the community answered

(59 responses)
  • A
    7% (4)
  • B
    88% (52)
  • C
    5% (3)

Explanation

Option B is true because PEP 8 recommends making object type comparisons using the isinstance() method instead of comparing types directly 1. Option D is true because PEP 8 recommends not writing string literals that rely on significant trailing whitespaces as they may be visually indistinguishable, and certain editors may trim them 1.

Topics

#PEP 8#isinstance#type comparison#trailing whitespace

Community Discussion

No community discussion yet for this question.

Full PCPP-32-101 Practice