Python Institute PCPP-32-101 Exam Practice Questions (P. 4)
- Full Access (45 questions)
- Six months of Premium Access
- Access to one million comments
- Seamless ChatGPT Integration
- Ability to download PDF files
- Anki Flashcard files for revision
- No Captcha & No AdSense
- Advanced Exam Configuration
Question #16
Which of the following examples using line breaks and different indentation methods are compliant with PEP 8 recommendations? (Choose two.)
send
light_mode
delete
Question #17
Look at the following examples of comments and docstrings in Python Select the ones that are useful and compliant with PEP 8 recommendations. (Choose two.)
- A
- BMost Voted
- CMost Voted
- Dprice = price + 1 # Decrement price by one to compensate for loss.
Correct Answer:
AB
AB
send
light_mode
delete
Question #18
Select the true statement related to PEP 257.
- AString literals that occur immediately after another docstring are called attribute docstrings
- BAttribute docstrings and Additional docstrings are two types of extra docstrings that can be extracted by software toolsMost Voted
- CString literals that occur in places other than the first statement in a module, function, or class definition can act as documentation. They are recognized by the Python bytecode compiler, and are accessible as runtime object attributes.
- DString literals that occur immediately after a simple assignment at the top level of a module are called complementary docstrings
Correct Answer:
C
C
send
light_mode
delete
Question #19
Select the true statements related to PEP 8 programming recommendations for code writing. (Choose two.)
- AYou should use the not ... is operator (e.g. if not spam is None:), rather than the is not operator (e.g. if spam is not None:), to increase readability.
- BYou should make object type comparisons using the isinstance() method (e.g. if isinstance(obj , int):) instead of comparing types directly (e.g. if type(obj) is type(1)).
- CYou should write code in a way that favors the CPython implementation over PyPy, Cython, and Jython.
- DYou should not write string literals that rely on significant trailing whitespaces, as they may be visually indistinguishable, and certain editors may trim them.
Correct Answer:
BD
BD
send
light_mode
delete
Question #20
Select the true statements related to PEP 8 naming conventions. (Choose two.)
- AFunction and variable names should be lower-case with words separated by underscores.Most Voted
- BYou should always use self as the first argument to instance methods, and cls as the first argument to class methods.Most Voted
- CModules should have short names written in CamelCase.
- DConstants should be written in all lower-case letters with words separated by underscores.
Correct Answer:
AD
AD
send
light_mode
delete
All Pages