Big Halloween Sale Discount Flat 70% Offer - Ends in 0d 00h 00m 00s - Coupon code: 70diswrap

Python Institute PCAP-31-03 Dumps

Page: 1 / 15
Total 154 questions

Certified Associate in Python Programming Questions and Answers

Question 1

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

Options:

A.

two

B.

zero

C.

one

D.

three

Question 2

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

as

Options:

A.

10

B.

the variable becomes unavailable

C.

11

D.

9

Question 3

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

Options:

A.

.3423e2

B.

3423e-2

C.

.3423e-2

D.

3423e2

Question 4

The__bases__property contains:

Options:

A.

base class locations (addr)

B.

base class objects (class)

C.

base class names (str)

D.

base class ids (int)

Question 5

What is the expected behavior of the following code?

as

Options:

A.

Its outputs 321

B.

It raises an exception.

C.

It outputs 6.

D.

It outputs 123.

Question 6

A class constructor (Select two answers)

Options:

A.

can return a value

B.

cannot be invoked directly from inside the class

C.

can be invoked directly from any of the subclasses

D.

can be invoked directly from any of the superclasses

Question 7

What is the expected output of the following code?

as

Options:

A.

abcef

B.

The program will cause a runtime exception error

C.

acdef

D.

abdef

Question 8

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

string = 'SKY' (:: -1)

string = string (-1)

Options:

A.

string is None

B.

string (0) == string (-1

C.

string (0) == 'Y'

D.

len (string) == 1

Question 9

Which line can be used instead of the comment to cause the snippet to produce the following expected output? (Select two answers)

Expected output:

1 2 3

Code:

as

Options:

A.

c, b, a = b, a, c

B.

c, b, a = a, c, b

C.

a, b, c = c, a, b

D.

a, b, c = a, b, c

Question 10

What is the expected behavior of the following code?

as

Options:

A.

it raises an exception

B.

it outputs True

C.

it outputs False

D.

it outputs nothing

Question 11

What is the expected behavior of the following code?

as

Options:

A.

it outputs -2

B.

it outputs 2. 0

C.

it outputs 0. 0

D.

the code is erroneous and it will not execute

Question 12

Assuming that the following inheritance set is in force, which of the following classes are declared properly? (Select two answers)

as

Options:

A.

class Class_4 (D, A) : pass

B.

class Class_1(C,D): pass

C.

class Class_3(A,C): pass

D.

class Class_2(B,D): pass

Question 13

Assuming that the following code has been executed successfully, selected the expression which evaluate to True (Select two answers)

as

Options:

A.

a ( ) == 4

B.

a is not None

C.

b ( ) == 4

D.

a ! = b

Question 14

What is the expected behavior of the following code?

as

Options:

A.

it outputs 2

B.

the code is erroneous and it will not execute

C.

it outputs 1

D.

it outputs 3

Question 15

You are going to read 16 bytes from a binary file into a bytearray called data. Which lines would you use? (Select two answers)

Options:

A.

data = bytearray (16) bf.readinto (data)

B.

data = binfile.read (bytearray (16))

C.

bf. readinto (data = bytearray (16))

D.

data = bytearray (binfile.read (16))

Question 16

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

Options:

A.

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

B.

II in ASCII stands for Internal Information

C.

ASCII is a subset of UNICODE

D.

a code point is a number assigned to a given character

Question 17

What is the expected behavior of the following snippet?

as

It will:

Options:

A.

cause a runtime exception

B.

print 1

C.

print 0 , [1]

D.

print [1J

Question 18

The following expression

1+-2

is:

Options:

A.

equal to 1

B.

invalid

C.

equal to 2

D.

equal to -1

Question 19

A Python module named pymod.py contains a variable named pyvar.

Which of the following snippets will let you access the variable? (Select two answers)

Options:

A.

import pyvar from pymod pyvar = 1

B.

from pymod import pyvar = 1

C.

from pymod import pyvar pyvar ()

D.

import pymod pymod.pyvar = 1

Question 20

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

import random

v1 = random. random()

v2 = random. random()

Options:

A.

len(random.sample([1,2,3],2)) > 2

B.

v1 == v2

C.

random.choice([1,2,3]) >=1

D.

v1 >= 1

Question 21

What is the expected output of the following snippet?

as

Options:

A.

3

B.

1

C.

2

D.

the code is erroneous

Question 22

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

Question 23

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

Options:

A.

121 +1 == int ('1' + 2 * '2')

B.

float ('3.14') == str('3.'+'14')

C.

'xyz'.lower() 'XY'

D.

'8' + '8' !=2 * '8'

Question 24

What is the expected behavior of the following code?

as

It will

Options:

A.

print 2 1

B.

print 1 2

C.

cause a runtime exception

D.

print

Question 25

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

Options:

A.

str(1-1) in '012345£739'[:2]

B.

'phd' in 'alpha'

C.

'deb' not in 'abcde' [::-1]

D.

'True' not in 'False'

Question 26

Which of the following invocations are valid? (Select two answers)

Options:

A.

rfind("python","r")

B.

sorted("python")

C.

"python".sort ()

D.

"python".index("th")

Question 27

There is a stream named s open for writing. What option will you select to write a line to the stream''

Options:

A.

s.write("Hello\n")

B.

write(s, "Hello")

C.

s.writeln("Hello")

D.

s.writeline("Hello")

Question 28

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

as

Options:

A.

sequential

B.

named

C.

positional

D.

keyword

Question 29

The following class hierarchy is given. What is the expected out of the code?

as

Options:

A.

BB

B.

CC

C.

AA

D.

BC

Question 30

What is the expected behavior of the following code?

as

It will:

Options:

A.

print 0

B.

cause a runtime exception

C.

prints 3

D.

print an empty line

Question 31

Which of the following lines of code will work flawlessly when put independently inside the add_new () method in order to make the snippet's output equal to [0, 1, 21 ? (Select two answers)

as

Options:

A.

self.queue.append(get_Iast() + 1)

B.

queue.append(self.get last () + 1)

C.

self.queue.append(self.queue[+1]

D.

self.queue.append(self.get last() +1)

Question 32

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

Question 33

What is the expected output of the following code?

as

Options:

A.

21

B.

2

C.

3

D.

12

Question 34

What is the expected behavior of the following code?

as

Options:

A.

it outputs 1

B.

it outputs 0

C.

it raises an exception

D.

it outputs 2

Question 35

With regards to the directory structure below, select the proper forms of the directives in order to import module_c. (Select two answers)

as

Options:

A.

from pypack.upper.lower import module_c

B.

import pypack.upper.lower.module_c

C.

import upper.module_c

D.

import upper.lower.module_c

Question 36

What is the expected behavior of the following code?

as

Options:

A.

It outputs 3.

B.

It outputs 1.

C.

It outputs 6.

D.

It raises an exception

Question 37

What is the expected behavior of the following code?

as

Options:

A.

It outputs False

B.

It outputs nothing

C.

It outputs True

D.

It raises an exception

Question 38

Assuming that the code below has been placed inside a file named code.py and executed successfully, which of the following expressions evaluate to True? (Select two answers)

as

Options:

A.

str(Object) == 'Object'

B.

_name == _main_'

C.

ClassA. _module_ == 'ClassA'

D.

len(ClassB.__bases__) == 1

Question 39

A compiler is a program designed to (select two answers)

Options:

A.

rearrange the source code to make it clearer

B.

check the source code in order to see if its correct

C.

execute the source code

D.

translate the source code into machine code

Question 40

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]

Options:

A.

zero

B.

five

C.

seven

D.

three

Question 41

What is the expected behavior of the following code?

as

Options:

A.

it outputs 0

B.

it outputs 1

C.

it raises an exception

D.

it outputs 2

Question 42

An operator able to perform bitwise shifts is coded as (select two answers)

Options:

A.

- -

B.

++

C.

<<

D.

>>

Question 43

How many lines does the following snippet output?

as

Options:

A.

three

B.

one

C.

two

D.

four

Question 44

What can you do if you don't like a long package path tike this one0 import alpha.beta.gamma.delta.epsiIon.zeta

Options:

A.

you can make an alias for the name using the a 1 i a s 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 die as keyword

Question 45

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

as

Options:

A.

1

B.

0

C.

2

D.

the variable becomes unavailable

Question 46

What is true about the following snippet? (Select two answers)

as

Options:

A.

the code will raise an unhandled exception

B.

the string I feel fine 'will be seen

C.

the string it's nice to see you will be seen

D.

the string what a pity will be seen

Page: 1 / 15
Total 154 questions