Summer Sale Special - Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: mxmas70

Home > Python Institute > PCPP1 > PCPP-32-101

PCPP-32-101 PCPP1 – Certified Professional in Python Programming 1 Question and Answers

Question # 4

A socket object is usually created by which one of the following invocations?

A.

socket. socket (socket_domain, socket_type)

B.

socket = socket. socket (socket_number)

C.

socket = socket. socket (socket_domain, socket_type, server_address)

D.

socket = socket.socket(server address)

Full Access
Question # 5

Which of the following methods allow you to load a configuration using ConfigParser? (Select two answers.)

A.

read

B.

read_dict

C.

read_conf

D.

read_str

Full Access
Question # 6

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()

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.

Full Access
Question # 7

Analyze the following snippet and choose the best statement that describes it.

A.

self. name is the name of a class variable.

B.

varl is the name of a global variable

C.

Excalibur is the value passed to an instance variable

D.

Weapon is the value passed to an instance variable

Full Access
Question # 8

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

A.

my_dict = {

"X": "180.A",

"Y": "206.P",

"Z": "12.C"

}

B.

spam = my_function(arg_one,

arg_two,

arg_three,

arg_four)

C.

foo = my_function

(arg_one, arg_two,

arg_three, arg_four

)

D.

my_dict = { "A" : "1", "B" : "2", "C" : "1" }

Full Access
Question # 9

Look at the following examples of comments and docstrings in Python. Select the ones that are useful and compliant with PEP 8 recommendations. (Select the two best answers.)

A.

def net_expense(q, price):

"""Return the total cost of items before tax."""

return q * price

B.

n = n - 1 # Decrement n by 1.

C.

val = val + 1.15 # Compensate for diminished value.

D.

def total_cost(q):

'''Takes the q argument and multiplies it by 1.15.'''

return q * 1.15

Full Access
Question # 10

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

A.

Serialization

B.

Inheritance

C.

Encapsulation

D.

Polymorphism

Full Access
Question # 11

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

A.

w. f ixshape ()

B.

w. f ixdim ()

C.

w. resizable ()

D.

w.makewindow ()

Full Access
Question # 12

What will be the content of the cars.xml file when you run the following code?

import xml.etree.ElementTree as ET

root = ET.Element('data')

car_1 = ET.SubElement(root, 'car', {'brand': 'Audi'})

car_2 = ET.SubElement(root, 'car', {'brand': 'Volkswagen'})

tree = ET.ElementTree(root)

tree.write('cars.xml', 'UTF-8', True)

A.

< data > < car brand="Audi" / > < car brand="Volkswagen" / > < /data >

B.

< ?xml version='1.0'? >

< data > < car brand="Audi" / > < car brand="Volkswagen" / > < /data >

C.

< ?xml version='1.0' encoding='UTF-8'? >

< data > < car brand="Audi" / > < car brand="Volkswagen" / > < /data >

D.

< ?xml? >

< data > < car brand="Audi" / > < car brand="Volkswagen" / > < /data >

Full Access
Question # 13

Which function or operator should you use to obtain the answer True or False to the question: "Do two variables refer to the same object?"

A.

The = operator

B.

The isinstanceO function

C.

The id () function

D.

The is operator

Full Access
Question # 14

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:

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:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Full Access
Question # 15

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

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.

Full Access
Question # 16

Which methods can be invoked in order to draw a triangle?

(Select two answers.)

A.

create_shape()

B.

create_line()

C.

create_triangle_shape()

D.

create_polygon()

Full Access
Question # 17

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 Iiterals 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

Full Access
Question # 18

What will happen if the mam 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.

Full Access
Question # 19

Select the true statement about the socket. gaierror exception.

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.

Full Access
Question # 20

Analyze the following function and choose the statement that best describes it.

A.

It is an example of a decorator that accepts its own arguments.

B.

It is an example of decorator stacking.

C.

It is an example of a decorator that can trigger an infinite recursion.

D.

The function is erroneous.

Full Access