Big Halloween Sale Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: 70special

Python Institute PCAP-31-03 Certified Associate in Python Programming Exam Practice Test

Page: 1 / 15
Total 154 questions

Certified Associate in Python Programming Questions and Answers

Testing Engine

  • Product Type: Testing Engine
$37.5  $124.99

PDF Study Guide

  • Product Type: PDF Study Guide
$33  $109.99
Question 1

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)

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 2

The first parameter of each method:

Options:

A.

holds a reference to the currently processed object

B.

is always set to None

C.

is set to a unique random value

D.

is set by the first argument's value

Question 3

Assuming that the following snippet has been successfully executed, which of the equations are True? (Select two answers)

Options:

A.

len(a) == len (b)

B.

b[0] fe- 1 == a[0]

C.

a [0] == b [0]

D.

a[0] + 1 == b[0]

Question 4

What is the expected behavior of the following code?

Options:

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

Question 5

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 6

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)

Question 7

What is the expected output of the following code?

Options:

A.

2

B.

3

C.

4

D.

an exception is raised

Question 8

Files with the suffix .pyc contain:

Options:

A.

Python 4 source code

B.

backups

C.

temporary data

D.

semi-compiled Python code

Question 9

What is the expected behavior of the following code?

Options:

A.

It outputs 123

B.

it raises an exception

C.

it outputs 321

D.

it outputs 6

Question 10

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

Options:

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

Question 11

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

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

Question 12

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

Options:

A.

_upper_

B.

_bases_

C.

_ancestors_

D.

_super_

Question 13

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

Options:

A.

len ('' ' '') == 2

B.

len ( ' ' ' 12

34 ' ' ') == 4

C.

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

D.

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

Question 14

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 15

What is the expected behavior of the following code?

Options:

A.

It outputs False

B.

It outputs nothing

C.

It outputs True

D.

It raises an exception

Question 16

Assuming that the following code has been executed successfully, select the expressions which evaluate to True (Select two answers.)

Options:

A.

a is not None

B.

a ! =b

C.

b () ==4

D.

a () == 4

Question 17

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

Options:

A.

an integer value identifying an opened file

B.

an error code (0 means success)

C.

a stream object

D.

always None

Question 18

What is the expected behavior of the following code?

It will:

Options:

A.

print 4321

B.

print

C.

cause a runtime exception

D.

print 1234

Question 19

What is the expected behavior of the following code?

It will:

Options:

A.

print 0

B.

cause a runtime exception

C.

prints 3

D.

print an empty line

Question 20

What is the expected behavior of the following code?

Options:

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

Question 21

What is the expected output of the following code if existing_file is the name of a file located inside the working directory?

Options:

A.

1 2

B.

1 2 3

C.

1 3

D.

2 3

Question 22

Which of the following lines of code will work flawlessly when put independently inside the inc ( ) method in order to make the snippet’s output equal to 3? (Select two answers)

Options:

A.

put (self.prop + vaI)

B.

self.put (self.get ( ) + vaI)

C.

self.put (get ( ) + vaI)

D.

self.put (self.prop + vaI)

Question 23

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

Question 24

What is the expected behavior of the following code?

Options:

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]

Question 25

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

Question 26

Assuming that the following snippet has been successfully executed, which of the equations are False? (Select two answers)

Options:

A.

len(a)== len (b)

B.

a [0]-1 ==b [0]

C.

a[0] = b[0]

D.

b[0] - 1 == a[0]

Question 27

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

Options:

A.

is instance(obj_b,C)

B.

C._C__VarA == 2

C.

has atr (B, 'get')

D.

obj_c.get() == 2

Question 28

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

Options:

A.

10

B.

the variable becomes unavailable

C.

11

D.

9

Question 29

Python strings can be “glued” together using the operator:

Options:

A.

.

B.

&

C.

_

D.

+

Question 30

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

Options:

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

Question 31

What is the expected behavior of the following snippet?

It will:

Options:

A.

cause a runtime exception on line 02

B.

cause a runtime exception on line 01

C.

cause a runtime exception on line 03

D.

print3

Question 32

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

Options:

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

Question 33

What is the expected behavior of the following code?

Options:

A.

It outputs 2

B.

It outputs 0.

C.

It outputs 1.

D.

It raises an exception

Question 34

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

String[1:-2]

is shorter than the original string by:

Options:

A.

four chars

B.

three chars

C.

one char

D.

two chars

Question 35

What is the expected output of the following snippet?

Options:

A.

1

B.

4

C.

2

D.

3

Question 36

What is the expected output of the following code?

Options:

A.

21

B.

2

C.

3

D.

12

Question 37

What is the expected output of the following code?

Options:

A.

4

B.

16

C.

an exception is raised

D.

1

Question 38

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 39

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)

Question 40

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 41

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

Options:

A.

' t '.upper () in 'Thames'

B.

'in not' in 'not'

C.

'not' not in 'in'

D.

'a' not in 'ABC' .lower ()

Question 42

What is the expected output of the following snippet?

Options:

A.

abc

B.

The code will cause a runtime exception

C.

ABC

D.

123

Question 43

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

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 44

What is the expected behavior of the following code?

Options:

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

Question 45

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

Options:

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

Question 46

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

Options:

A.

'in not' in 'not'

B.

'in' in 'Thames'

C.

't' . upper ( ) in 'Thames'

D.

'in' in 'in'

Page: 1 / 15
Total 154 questions