Summer Special Discount 60% Offer - Ends in 0d 00h 00m 00s - Coupon code: brite60

ExamsBrite Dumps

Certified Associate in Python Programming Question and Answers

Certified Associate in Python Programming

Last Update Oct 15, 2025
Total Questions : 154

We are offering FREE PCAP-31-03 Python Institute exam questions. All you do is to just go and sign up. Give your details, prepare PCAP-31-03 free exam questions and then go for complete pool of Certified Associate in Python Programming test questions that will help you more.

PCAP-31-03 pdf

PCAP-31-03 PDF

$42  $104.99
PCAP-31-03 Engine

PCAP-31-03 Testing Engine

$50  $124.99
PCAP-31-03 PDF + Engine

PCAP-31-03 PDF + Testing Engine

$66  $164.99
Questions 1

What is the expected behavior of the following code?

Options:

A.  

it outputs 0

B.  

it outputs 1

C.  

it raises an exception

D.  

it outputs 2

Discussion 0
Questions 2

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

Options:

A.  

Python strings are actually lists

B.  

Python strings can be concatenated

C.  

Python strings can be sliced like lists

D.  

Python strings are mutable

Discussion 0
Questions 3

What is the expected output of the following code?

Options:

A.  

4

B.  

16

C.  

an exception is raised

D.  

1

Discussion 0
Questions 4

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

Discussion 0
Questions 5

What is the expected output of the following code?

Options:

A.  

21

B.  

2

C.  

3

D.  

12

Discussion 0
Questions 6

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

A)

B)

C)

D)

Options:

A.  

Option A

B.  

Option B

C.  

Option C

D.  

Option D

Discussion 0
Questions 7

If you want to transform a string into a list of words, what invocation would you use? (Select two answers)

Expected output:

Options:

A.  

s.split ()

B.  

split (s, "˜ "˜)

C.  

s.split ("˜ "˜)

D.  

split (s)

Discussion 0
Questions 8

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

Options:

A.  

- -

B.  

++

C.  

<<

D.  

>>

Discussion 0
Questions 9

What is the expected behavior of the following code?

Options:

A.  

it outputs 'None'

B.  

it outputs 3

C.  

it raises an exception

D.  

it outputs 0

Discussion 0
Questions 10

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

Discussion 0
Questions 11

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'

Discussion 0
Questions 12

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

Discussion 0
Questions 13

The following expression

1+-2

is:

Options:

A.  

equal to 1

B.  

invalid

C.  

equal to 2

D.  

equal to -1

Discussion 0
Questions 14

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

Options:

A.  

a is b

B.  

b( ) > 2

C.  

a() > 2

D.  

a is not None

Discussion 0
Questions 15

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]

Discussion 0
Questions 16

If you need to serve two different exceptions called Ex1 and Ex2 in one except branch, you can write:

Options:

A.  

except Ex1 Ex2:

B.  

except (ex1, Ex2):

C.  

except Ex1, Ex2:

D.  

except Ex1+Ex2:

Discussion 0
Questions 17

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

Options:

A.  

.

B.  

&

C.  

_

D.  

+

Discussion 0
Questions 18

Is it possible to safely check if a class object has a certain attribute0

Options:

A.  

yes, by using the hasattr attribute

B.  

yes. by using the hasattr () method

C.  

yes, by using the hasattr () function

D.  

no, it is not possible

Discussion 0
Questions 19

Which of the listed actions can be applied to the following tuple? (Select two answers)

Options:

A.  

tup [:]

B.  

tup.append (0)

C.  

tup [0]

D.  

del tup

Discussion 0
Questions 20

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

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

Discussion 0
Questions 21

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, 1] ? (Select two answers)

Options:

A.  

put self.store(1])

B.  

self put stire(1])

C.  

self .put self.get () [-1])

D.  

self .put (self.store[1])

Discussion 0
Questions 22

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

Discussion 0
Questions 23

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

Discussion 0
Questions 24

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)

Discussion 0
Questions 25

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

Discussion 0
Questions 26

What is the expected behavior of the following code?

Options:

A.  

it outputs 3

B.  

it outputs 1

C.  

it outputs 6

D.  

it raises an exception

Discussion 0
Questions 27

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

Options:

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

Discussion 0
Questions 28

What is the expected behavior of the following snippet?

It will:

Options:

A.  

cause a runtime exception

B.  

print 1

C.  

print 0 , [1]

D.  

print [1J

Discussion 0
Questions 29

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

Options:

A.  

closing an open file is performed by the closefile ( ) function

B.  

the second open ( ) argument describes the open mode and defaults to ‘w’

C.  

if open ( ) ‘s second argument is ‘r’ the file must exist or open will fail

D.  

if open ( )’s second argument is ‘w’ and the invocation succeeds, the previous file’s content is lost

Discussion 0
Questions 30

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

Options:

A.  

chr (ord (x)) = = x

B.  

ord (ord (x)) = = x

C.  

chr (chr (x)) = = x

D.  

ord (chr (x)) = = x

Discussion 0
Questions 31

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

Discussion 0
Questions 32

What is the expected output of the following code?

Options:

A.  

a

B.  

an exception is raised

C.  

b

D.  

c

Discussion 0
Questions 33

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

Options:

A.  

a ( ) == 4

B.  

a is not None

C.  

b ( ) == 4

D.  

a ! = b

Discussion 0
Questions 34

What is the expected behavior of the following code?

Options:

A.  

it outputs [1, 3]

B.  

the code is erroneous and it will not execute

C.  

it outputs [3, 1]

D.  

it outputs [4, 2, 0]

Discussion 0
Questions 35

What is the expected output of the following snippet?

Options:

A.  

True False

B.  

True True

C.  

False False

D.  

False True

Discussion 0
Questions 36

A variable stored separately in every object is called:

Options:

A.  

there are no such variables, all variables are shared among objects

B.  

a class variable

C.  

an object variable

D.  

an instance variable

Discussion 0
Questions 37

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

Discussion 0
Questions 38

The following class definition is given. We want the show () method to invoke the get () method, and then output the value the get () method returns. Which of the invocations should be used instead of XXX?

Options:

A.  

print (get(self))

B.  

print (self.get())

C.  

print (get())

D.  

print (self.get (val))

Discussion 0
Questions 39

What is the expected behavior of the following code?

Options:

A.  

it raises an exception

B.  

it outputs True

C.  

it outputs False

D.  

it outputs nothing

Discussion 0
Questions 40

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'

Discussion 0
Questions 41

What is the expected behavior of the following code?

Options:

A.  

it outputs 2

B.  

it raises an exception

C.  

it outputs 3

D.  

it outputs 5

Discussion 0
Questions 42

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:

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

Discussion 0
Questions 43

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

Discussion 0
Questions 44

What is the expected output of the following snippet?

Options:

A.  

1

B.  

4

C.  

2

D.  

3

Discussion 0
Questions 45

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

Options:

A.  

ch = read(s, 1)

B.  

ch = s. input(1)

C.  

ch = input(s, 1)

D.  

ch = s. read(l)

Discussion 0
Questions 46

What is the expected output of the following snippet?

Options:

A.  

the code is erroneous

B.  

3

C.  

7

D.  

15

Discussion 0