Certified Professional in Python Programming 1 v1.0

Page:    1 / 3   
Exam contains 45 questions

Which of the following examples using line breaks and different indentation methods are compliant with PEP 8 recommendations? (Choose two.)

  • A.
  • B.
  • C.
  • D.


Answer : AC

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.
  • B.
  • C.
  • D. price = price + 1 # Decrement price by one to compensate for loss.


Answer : BC

Select the true statement related to PEP 257.

  • A. String literals that occur immediately after another docstring are called attribute docstrings
  • B. Attribute docstrings and Additional docstrings are two types of extra docstrings that can be extracted by software tools
  • C. String 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.
  • D. String literals that occur immediately after a simple assignment at the top level of a module are called complementary docstrings


Answer : B

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

  • A. You 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.
  • B. You 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)).
  • C. You should write code in a way that favors the CPython implementation over PyPy, Cython, and Jython.
  • D. You should not write string literals that rely on significant trailing whitespaces, as they may be visually indistinguishable, and certain editors may trim them.


Answer : BD

Select the true statements related to PEP 8 naming conventions. (Choose two.)

  • 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 argument to class methods.
  • C. Modules should have short names written in CamelCase.
  • D. Constants should be written in all lower-case letters with words separated by underscores.


Answer : AB

Select the true statement about PEP 8 recommendations related to line breaks and binary operators.

  • A. It is recommended that you use line breaks before binary operators to improve code readability
  • B. It is permissible to use line breaks before or after a binary operator, as long as the convention is consistent locally. However, for new code, it is recommended that break lines should be used only after binary operators.
  • C. It is recommended that you use line breaks after binary operators to improve code readability
  • D. There is no specific PEP 8 recommendation related to using line breaks with binary operators


Answer : B

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

  • A. No whitespace immediately before the opening parenthesis that starts the list of arguments of a function call:
  • B. A whitespace immediately before a comma, semicolon, and colon:
  • C. No whitespace between a trailing comma and a following closing parenthesis:
  • D. A whitespace immediately after the opening parenthesis that starts indexing or slicing:


Answer : AC

Which of the following values can be returned by the messagebox.askquestion() method?

  • A. "accept" and "cancel"
  • B. l and 0
  • C. "yes" and "no"
  • D. True and False


Answer : C

What will happen if the main window is too small to fit all its widgets?

  • A. Some widgets may be invisible
  • B. The window will be expanded
  • C. An exception will be raised
  • D. The widgets will be scaled down to fit the window’s size


Answer : D

What is true about the unbind() method? (Choose two.)

  • A. It is invoked from within the event's object.
  • B. It is invoked from within a widget’s object
  • C. It needs a widget's object as an argument.
  • D. It needs the event name as an argument


Answer : BD

If purple can be obtained from mixing red and blue, which color codes represent the two ingredients? (Choose two.)

  • A. #FFFFFF
  • B. #0000FF
  • C. #FF0000
  • D. #000000


Answer : BC

What is true about the invocation of the cget() method?

  • A. It can be used to read widget attributes
  • B. It has the same effect as the config() method
  • C. It can be used to set new values to widget attributes
  • D. It can be replaced with a dictionary-like access manner


Answer : A

Which of the following will set the button text’s font to 12 point italics Arial? (Choose two.)

  • A. button.ButtonFont('Arial' , '12', 'italic')
  • B. button.setfont(('Arial', '12', 'italic'))
  • C. button=Button(wnd,font=('Arial', '12', 'italic')
  • D. button.config(font=('Arial', '12', 'italic'))


Answer : BD

What is true about the unbind_all() method? (Choose two.)

  • A. It can be invoked from any widget
  • B. It can be invoked from the main window widget only
  • C. It is parameterless
  • D. It causes all the widgets to disappear


Answer : AC

If w is a correctly created main application window, which method would you use to fix both of the main window's dimensions?

  • A. w.fixshape()
  • B. w.fixdim()
  • C. w.resizable()
  • D. w.makewindow()


Answer : C

Page:    1 / 3   
Exam contains 45 questions

Talk to us!


Have any questions or issues ? Please dont hesitate to contact us

Certlibrary.com is owned by MBS Tech Limited: Room 1905 Nam Wo Hong Building, 148 Wing Lok Street, Sheung Wan, Hong Kong. Company registration number: 2310926
Certlibrary doesn't offer Real Microsoft Exam Questions. Certlibrary Materials do not contain actual questions and answers from Cisco's Certification Exams.
CFA Institute does not endorse, promote or warrant the accuracy or quality of Certlibrary. CFA® and Chartered Financial Analyst® are registered trademarks owned by CFA Institute.
Terms & Conditions | Privacy Policy