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

PCAP-31-03 Questions and Answers

Question # 6

Which of the equations are True? (Select two answers)

A.

chr (ord (x)) = = x

B.

ord (ord (x)) = = x

C.

chr (chr (x)) = = x

D.

ord (chr (x)) = = x

Full Access
Question # 7

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

A.

len ('' ' '') == 2

B.

len ( ' ' ' 12

34 ' ' ') == 4

C.

chr (ord('z') - 1 == 'Y'

D.

ord (''0'') - ord (''9'') == 10

Full Access
Question # 8

What is a true about python class constructors? (Select two answers)

A.

the constructor must have at least one parameter

B.

the constructor must return a value other than None

C.

the constructor is a method named_init_

D.

there can the more than one constructor in a Python class.

Full Access
Question # 9

What is the expected behavior of the following code?

x - 3 % 1

y -1 if x > else 0

print (y)

A.

it outputs -1

B.

the code is erroneous and it will not execute

C.

it outputs 1

D.

it outputs 0

Full Access
Question # 10

How many elements will the list2 list contain after execution of the following snippet?

list1 = [False for i in range (1, 10) ]

list2 = list1 [-1:1:-1]

A.

zero

B.

five

C.

seven

D.

three

Full Access
Question # 11

How many lines does the following snippet output?

A.

three

B.

one

C.

two

D.

four

Full Access
Question # 12

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)

A.

From pymod import ‘

Pymod.pyfun ( )

B.

Import pymod

Pymod. Pyfun ( )

C.

Import pyfun from pymod

Pyfun ( )

D.

From pymod import pyfun

Pyfun ( )

Full Access
Question # 13

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

A.

the__name__variable content determines the way in which the module was run

B.

a package can be stored as a tree of sub-directories/sub-folders

C.

__pycache__is the name of a built-in variable

D.

hashbang is the name of a built-in Python function

Full Access
Question # 14

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

Full Access
Question # 15

The__bases__property contains:

A.

base class locations (addr)

B.

base class objects (class)

C.

base class names (str)

D.

base class ids (int)

Full Access
Question # 16

Which of the following literals reflect the value given as 34.23? (select two answers)

A.

.3423e2

B.

3423e-2

C.

.3423e-2

D.

3423e2

Full Access
Question # 17

What is the expected behavior of the following code?

A.

it outputs 2

B.

it raises an exception

C.

it outputs 3

D.

it outputs 5

Full Access
Question # 18

You need data which can act as a simple telephone directory. You can obtain it with the following clauses (choose two relevant variants; assume that no other items have been created before)

A.

dir={'Mom':5551234567, 'Dad':5557654321>

B.

dir={'Mom':'5551234567', * Dad':'5557654321'}

C.

dir={Mom:5551234567, Dad:5557654321}

D.

dir={Mom:'5551234567', Dad:'5557654321'}

Full Access
Question # 19

Select the valid fun () invocations:

(select two answers)

def fun (a, b=0):

return a*b

A.

fun(b=1)

B.

fun (a=0)

C.

fun(b=1, 0)

D.

fun (1)

Full Access
Question # 20

What is the expected behavior of the following code?

A.

it outputs list assignment index out of range

B.

the code is erroneous and it will not execute

C.

it outputs

D.

it outputs error

Full Access
Question # 21

What is the expected output of the following snippet?

A.

True lower

B.

True upper

C.

False upper

D.

False lower

Full Access
Question # 22

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

Full Access
Question # 23

A method for passing the arguments used by the following snippet is called:

A.

sequential

B.

named

C.

positional

D.

keyword

Full Access
Question # 24

What is the expected output of the following code if there is no file named non existing_file inside the working directory?

A.

2 2

B.

1 3

C.

1 2 3

D.

2 2 3

Full Access
Question # 25

A property that stores information about a given class's super-classes is named:

A.

_upper_

B.

_bases_

C.

_ancestors_

D.

_super_

Full Access
Question # 26

What is the expected behavior of the following code?

A.

the code is erroneous and it will not execute

B.

it outputs 'tuple' object does not support item assignment

C.

0it outputs list assignment index out of range

D.

it outputs None

Full Access
Question # 27

Python's built-in function named open () tries to open a file and returns:

A.

an integer value identifying an opened file

B.

an error code (0 means success)

C.

a stream object

D.

always None

Full Access
Question # 28

What is the expected behavior of the following code?

A.

it outputs -2

B.

it outputs 2. 0

C.

it outputs 0. 0

D.

the code is erroneous and it will not execute

Full Access
Question # 29

Assuming that the following code has been executed successfully, select the expressions which evaluate to true.

(Select two answers.)

A.

a == b

B.

b {1} == 4

C.

a is not None

D.

a (2) == 4

Full Access
Question # 30

Which of the following words can be used as a variable name? (Select two valid names)

A.

for

B.

True

C.

true

D.

For

Full Access
Question # 31

Assuming that String is six or more letters long, the following slice

String[1:-2]

is shorter than the original string by:

A.

four chars

B.

three chars

C.

one char

D.

two chars

Full Access
Question # 32

How many elements will the list1 list contain after execution of the following snippet?

A.

two

B.

zero

C.

one

D.

three

Full Access
Question # 33

What is the expected behavior of the following code?

A.

It outputs 3.

B.

It outputs 1.

C.

It outputs 6.

D.

It raises an exception

Full Access
Question # 34

What is the expected behavior of the following code?

A.

the code is erroneus and it will not execute

B.

it outputs [2, 4]

C.

it outputs [4, 2]

D.

it outputs [0, 1, 2, 3, 4]

Full Access
Question # 35

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

A.

'in not' in 'not'

B.

'in' in 'Thames'

C.

't' . upper ( ) in 'Thames'

D.

'in' in 'in'

Full Access
Question # 36

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

Full Access
Question # 37

What is the expected behavior of the following code?

A.

it outputs False

B.

it outputs True

C.

it raises an exception

D.

it outputs nothing

Full Access
Question # 38

What is the expected behavior of the following code?

A.

it outputs error

B.

it outputs list assignment index out of range

C.

the code is erroneous and it will not execute

D.

it outputs

Full Access
Question # 39

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

A.

a code point is a point inside the code when execution stops immediately

B.

an escape sequence can be recognized by the # sign put in front of it.

C.

UTF-8 is one of the ways of representing UNICODE code points.

D.

ASCII is the name of a character coding standard

Full Access
Question # 40

Is it possible to safely check if a class/object has a certain attribute?

A.

yes, by using the hasattr attribute

B.

yes, by using the hasattr ( ) method

C.

yes, by using the hassattr ( ) function

D.

no, it is not possible

Full Access
Question # 41

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

A.

encapsulation allows you to protect some data from uncontrolled access

B.

the arrows on a class diagram are always directed from a superclass towards its subclass

C.

inheritance is the relation between a superclass and a subclass

D.

an object is a recipe for a class

Full Access
Question # 42

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

Full Access
Question # 43

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

A.

ch = read(s, 1)

B.

ch = s. input(1)

C.

ch = input(s, 1)

D.

ch = s. read(l)

Full Access
Question # 44

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

Full Access
Question # 45

What is the expected behavior of the following code?

It will:

A.

print 4321

B.

print

C.

cause a runtime exception

D.

print 1234

Full Access
Question # 46

What is the expected behavior of the following code?

A.

it outputs 1

B.

it outputs 2

C.

the code is erroneous and it will not execute

D.

it outputs 3

Full Access