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

Python Institute PCAP-31-03 - Certified Associate in Python Programming

Page: 3 / 5
Total 154 questions

What is the expected output of the following code?

A.

a

B.

an exception is raised

C.

b

D.

c

What is the expected behavior of the following code?

A.

it outputs 6

B.

it outputs 1

C.

it outputs 3

D.

it raises an exception

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

A.

1

B.

0

C.

2

D.

the variable becomes unavailable

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

A.

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

B.

the second open () argument is optional

C.

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

D.

if invoking open () fails, the value None is returned

What is true about Python packages? (Select two answers)

A.

the sys.path variable is a list of strings

B.

_pycache_is a folder that stores semi-completed Python modules

C.

a package contents can be stored and distributed as an mp3 file

D.

a code designed to initialize a package's state should be placed inside a file named init.py

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

A.

class X:

B.

class X:

pass

C.

class X:

return

D.

class X: {}

What is true about Object-Oriented Programming in Python? (Select two answers)

A.

if a real-life object can be described with a set of adjectives, they may reflect a Python object method

B.

the same class can be used many times to build a number of objects

C.

each object of the same class can have a different set of methods

D.

a subclass is usually more specialized than its superclass

What can you do if you don’t like a long package path like this one?

A.

you can make an alias for the name using the alias keyword

B.

nothing, you need to come to terms with it

C.

you can shorten it to alpha. zeta and Python will find the proper connection

D.

you can make an alias for the name using the as keyword

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]

A.

string[0] == string[-1]

B.

string is None

C.

len (string] == 3

D.

string[0] == 'o'

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

A.

1

B.

0

C.

-1

D.

an exception is raised