Pass the Python Institute PCAP PCAP-31-03 Questions and answers with CertsForce

Viewing page 3 out of 5 pages
Viewing questions 21-30 out of questions
Questions # 21:

Which of the following expressions evaluate to True? (Select two answers)

Options:

A.

121 + 1 != '!' + 2 * '2'


B.

'AbC' lower () < 'AB'


C.

'1' + '1' + '1' < '1' * 3'


D.

'3.14' != str(3.1415)


Expert Solution
Questions # 22:

What is true about Python class constructors? (Choose two.)

Options:

A.

there can be more than one constructor in a Python class


B.

the constructor must return a value other than None


C.

the constructor is a method named __init__


D.

the constructor must have at least one parameter


Expert Solution
Questions # 23:

What will the value of the i variable be when the following loop finishes its execution?

Question # 23

Options:

A.

10


B.

the variable becomes unavailable


C.

11


D.

9


Expert Solution
Questions # 24:

Which of the following lambda definitions are correct? (Select two answers)

Options:

A.

lanbda x, y; return x\\y - x%y


B.

lambda x, y: x//y - x%y


C.

lambda (x, y = x\\y x%y


D.

lambda x, y: (x, y)


Expert Solution
Questions # 25:

Which of the following statements are true? (Select two answers)

Options:

A.

\e is an escape sequence used to mark the end of lines


B.

ASCII is synonymous with UTF-8


C.

II in ASCII stands for Information Interchange


D.

a code point is a number assigned to a given character


Expert Solution
Questions # 26:

If you want to access an exception object's components and store them in an object called e, you have to use the following form of exception statement

Options:

A.

except Exception(e):


B.

except e=Exception:


C.

except Exception as e:


D.

such an action is not possible in Python


Expert Solution
Questions # 27:

You are going to read just one character from a stream called s. Which statement would you use?

Options:

A.

ch = read(s, 1)


B.

ch = s. input(1)


C.

ch = input(s, 1)


D.

ch = s. read(l)


Expert Solution
Questions # 28:

The simplest possible class definition in Python can be expressed as:

Options:

A.

class X:


B.

class X:

pass


C.

class X:

return


D.

class X: {}


Expert Solution
Questions # 29:

Which of the following statements are true? (Select two answers)

Options:

A.

open () requires a second argument


B.

open () is a function which returns an object that represents a physical file


C.

instd, outstd, errstd are the names of pre-opened streams


D.

if invoking open () fails, an exception is raised


Expert Solution
Questions # 30:

What is the expected behavior of the following code?

x = 8 ** (1/3)

y = 2. if x < 2.3 else 3.

print(y)

Options:

A.

it outputs 2.0


B.

it outputs 2. 5


C.

the code is erroneus and it will not execute


D.

it outputs 3.0


Expert Solution
Viewing page 3 out of 5 pages
Viewing questions 21-30 out of questions