Summer Sale Discount Flat 70% Offer - Ends in 0d 00h 00m 00s - Coupon code: 70diswrap

Python Institute PCPP-32-101 Dumps

Page: 1 / 7
Total 69 questions

PCPP1 – Certified Professional in Python Programming 1 Questions and Answers

Question 1

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

Options:

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 ismstanceQ method (e.g. if isinstance (obj, int) :) instead of comparing types directly (eg if type(obj) is type(i)).

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

Question 2

Select the true statement about the socket. gaierror exception.

Options:

A.

It is raised when a timeout occurs on a socket.

B.

It is raised when a system function returns a system-related error.

C.

It is raised when an address-related error caused by the repr () function occurs.

D.

It is raised when an address-related error caused by the getaddrinfo () and getnameinfo () functions occurs.

Question 3

Select the true statements about the sqlite3 module. (Select two answers.)

Options:

A.

The fetchalt method returns None when no rows are available

B.

The execute method allows you to perform several queries at once

C.

The execute method is provided by the Cursor class

D.

The fetchone method returns None when no rows are available

Question 4

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

Options:

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.

Question 5

Select the true statements related to PEP 8 programming recommendations for exception handling. (Select two answers.)

Options:

A.

When designing exception hierarchies, you should focus on stating that a problem occurred, rather than programmatically trying to answer the question about what actually went wrong.

B.

You should generally use “bare” except: clauses, as they will not catch SystemExit and KeyboardInterrupt exceptions, making it more difficult to interrupt a program using keyboard shortcuts.

C.

You should derive exceptions from the Exception class, rather than from the BaseException class.

D.

You should generally limit the use of a “bare” except: clause and, whenever possible, use specific exceptions instead.

Question 6

The following snippet represents one of the OOP pillars Which one is that?

as

Options:

A.

Serialization

B.

Inheritance

C.

Encapsulation

D.

Polymorphism

Question 7

Which of the following statements regarding the __traceback__ attribute are true?

(Select two answers.)

Options:

A.

The attribute is a special method delivered by the traceback module to retrieve a full list of strings describing the traceback.

B.

The attribute can be easily handled by the traceback.format_tb() method.

C.

The attribute is owned by every exception object.

D.

The attribute is owned only by the exception objects residing in an exception chain.

Question 8

Which of the following constants will be used if you do riot define the quoting argument in the writer method provided by the csv module?

Options:

A.

csv.QUOTE_MINIMAL

B.

csv.QUOTE_NONE

C.

svQUOTE_ALL

D.

csv.QUOTE_NONNUMERIC

Question 9

What is true about the constructor’s argument, which sets the button’s title to a desired string?

Options:

A.

It is the second argument of the constructor.

B.

It is the third argument of the constructor.

C.

It is a keyword argument named title.

D.

It is a keyword argument named text.

Question 10

What is true about the following snippet of code?

class Cat:

def __init__(self, weight, sex):

self.height = height

self.weight = weight

self.sex = sex

def say(self):

print('meows')

kitty = Cat(1, 'male')

kitty.say()

Options:

A.

The snippet will print: 1 male.

B.

The snippet will cause a NameError exception.

C.

The snippet will print: meows.

D.

The snippet will cause a ValueError exception.

Question 11

The following JSON string:

{ 1 }

Options:

A.

is erroneous

B.

is an object

C.

is an array

D.

is an integer

Question 12

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

A)

No whitespace immediately before the opening parenthesis that starts the list of arguments of a function call:

as

B)

A whitespace immediately before a comma, semicolon, and colon:

as

C)

No whitespace between a trailing comma and a following closing parenthesis:

as

D)

A whitespace immediately after the opening parenthesis that starts indexing or slicing:

as

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 13

What is ElementTree?

Options:

A.

A Python built-in module that contains functions used for creating HTML files.

B.

A Python library that contains an API used for parsing and manipulating JSON files.

C.

A Python library that contains functions and tools used for manipulating text files in GUI Programming.

D.

A Python built-in module that contains functions used for parsing and creating XML data.

Question 14

Which sentence about the ©property decorator is false?

Options:

A.

The ©property decorator should be defined after the method that is responsible for setting an encapsulated attribute.

B.

The @property decorator designates a method which is responsible for returning an attribute value

C.

The ©property decorator marks the method whose name will be used as the name of the instance attribute

D.

The ©property decorator should be defined before the methods that are responsible for setting and deleting an encapsulated attribute

Question 15

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

Options:

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.

Question 16

Analyze the following snippet and decide whether the code is correct and/or which method should be distinguished as a class method.

as

Options:

A.

There is only one initializer, so there is no need for a class method.

B.

The getNumberofCrosswords () method should be decorated With @classmethod.

C.

The code is erroneous.

D.

The gexNumberOfcrosswords () and issrived methods should be decorated with @classzoechod.

Question 17

Select a log that matches the following format:

'%(name)s[%(levelname)s][%(asctime)s] :%(message)s'

Options:

A.

root[CRITICAL][2019-10-19 18:21:35] :Invalid argument

B.

root:CRITICAL:2019-10-19 18:21:35,407:Invalid argument

C.

root[CRITICAL][2019-10-19 18:21:35,407] :Invalid argument

D.

root:CRITICAL:2019-10-19 18:21:35:Invalid argument

Question 18

Select the true statements about the json.-dumps () function. (Select two answers.)

Options:

A.

It returns a JSON string.

B.

It returns a Python entity.

C.

It takes a JSON string as its argument

D.

It takes Python data as its argument.

Question 19

Which one of the following methods allows you to debug an XML tree in the xml.etree ELementTree module?

Options:

A.

debug

B.

dump

C.

log

D.

parse

Question 20

Select the true statements about the sqirte3 module. (Select two answers.)

Options:

A.

The sqlite3 module provides an interface compliant with the DB-API 2.0.

B.

The special name memory is used to create a database in RAM.

C.

The sqhte3 module does not support transactions.

D.

The fetchall method returns an empty list when no rows are available

Page: 1 / 7
Total 69 questions