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

Viewing page 2 out of 5 pages
Viewing questions 11-20 out of questions
Questions # 11:

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

Options:

A.

lambda X : None


B.

lambda : 3,1415


C.

lambda x : def fun(x): return x


D.

lambda lambda: lambda * lambda


Expert Solution
Questions # 12:

What is the expected behavior of the following snippet?

Question # 12

It will:

Options:

A.

cause a runtime exception


B.

print 1


C.

print 0 , [1]


D.

print [1J


Expert Solution
Questions # 13:

What is the expected output of the following code if the file named existing_text_file is a non-zero length text file located inside the working directory?

Question # 13

Options:

A.

the length of the first line from the file


B.

-1


C.

the number of lines contained inside the file


D.

the length of the last line from the file


Expert Solution
Questions # 14:

What is the expected output of the following snippet?

Question # 14

Options:

A.

3


B.

1


C.

2


D.

the code is erroneous


Expert Solution
Questions # 15:

What is the expected output of the following code?

def foo(x,y,z):

return x(y) - x(z)

print{f00(lambda x: x % 2, 2, 1) )

Options:

A.

1


B.

0


C.

-1


D.

an exception is raised


Expert Solution
Questions # 16:

The following expression

1+-2

is:

Options:

A.

equal to 1


B.

invalid


C.

equal to 2


D.

equal to -1


Expert Solution
Questions # 17:

A Python module named pymod, py contains a function named pyfun ( ).

Which of the following snippets will let you invoke the function? (Select two answers)

Options:

A.

From pymod import ‘

Pymod.pyfun ( )


B.

Import pymod

Pymod. Pyfun ( )


C.

Import pyfun from pymod

Pyfun ( )


D.

From pymod import pyfun

Pyfun ( )


Expert Solution
Questions # 18:

Assuming that the snippet below has been executed successfully, which of the following expressions will evaluate to True? (Select two answers)

string = 'python' [::2]

string = string[-1] + string[-2]

Options:

A.

string[0] == string[-1]


B.

string is None


C.

len (string] == 3


D.

string[0] == 'o'


Expert Solution
Questions # 19:

Can a module run like regular code?

Options:

A.

yes, and it can differentiate its behavior between the regular launch and import


B.

it depends on the Python version


C.

yes, but it cannot differentiate its behavior between the regular launch and import


D.

no. it is not possible; a module can be imported, not run


Expert Solution
Questions # 20:

If you need a function that does nothing, what would you use instead of XXX? (Select two answers)

def idler ( ):

XXX

Options:

A.

pass


B.

return


C.

exit


D.

None


Expert Solution
Viewing page 2 out of 5 pages
Viewing questions 11-20 out of questions