Spring Sale Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: pass65

PCAP-31-03 Certified Associate in Python Programming Questions and Answers

Questions 4

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

Buy Now
Questions 5

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

Buy Now
Questions 6

What is the expected output of the following code if the file named existing_text_file is a non-zero length text file located inside the working directory?

PCAP-31-03 Question 6

Options:

A.

the length of the first line from the file

B.

-1

C.

the number of lines contained inside the file

D.

the length of the last line from the file

Buy Now
Questions 7

What is the expected behavior of the following code?

PCAP-31-03 Question 7

Options:

A.

It outputs 123

B.

it raises an exception

C.

it outputs 321

D.

it outputs 6

Buy Now
Questions 8

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

Buy Now
Questions 9

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)

PCAP-31-03 Question 9

Options:

A.

str (Object) = ' Object1

B.

Class A.__module__ == ' main__ '

C.

len (ClassB.__bases__) == 2

D.

__name__== ' __main__ '

Buy Now
Questions 10

The following expression

1+-2

is:

Options:

A.

equal to 1

B.

invalid

C.

equal to 2

D.

equal to -1

Buy Now
Questions 11

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

Expected output:

PCAP-31-03 Question 11

Options:

A.

s.split ()

B.

split (s, " ˜ " ˜)

C.

s.split ( " ˜ " ˜)

D.

split (s)

Buy Now
Questions 12

What would you use instead of XXX if you want to check whether a certain ‘ key ' exists in a dictionary called diet? (Select two answers)

II

if XXX:

print( " Key exists " )

Options:

A.

' key ' in diet

B.

diet[ ' key ' ] != None

C.

diet.exists( ' key ' )

D.

' key ' in diet.keys()

Buy Now
Questions 13

What is the expected behavior of the following code?

PCAP-31-03 Question 13

Options:

A.

It outputs 3.

B.

It outputs 1.

C.

It outputs 6.

D.

It raises an exception

Buy Now
Questions 14

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

Options:

A.

1

B.

0

C.

-1

D.

an exception is raised

Buy Now
Questions 15

What is the expected output of the following code?

PCAP-31-03 Question 15

Options:

A.

2

B.

3

C.

4

D.

an exception is raised

Buy Now
Questions 16

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

Buy Now
Questions 17

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)

PCAP-31-03 Question 17

PCAP-31-03 Question 17

Options:

A.

put (self.prop + vaI)

B.

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

C.

self.put (get ( ) + vaI)

D.

self.put (self.prop + vaI)

Buy Now
Questions 18

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

PCAP-31-03 Question 18

Options:

A.

a is not None

B.

a ! =b

C.

b () ==4

D.

a () == 4

Buy Now
Questions 19

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

Buy Now
Questions 20

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

Buy Now
Questions 21

How many lines does the following snippet output?

PCAP-31-03 Question 21

Options:

A.

three

B.

one

C.

two

D.

four

Buy Now
Questions 22

What is the expected output of the following snippet?

PCAP-31-03 Question 22

Options:

A.

the code is erroneous

B.

3

C.

7

D.

15

Buy Now
Questions 23

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:

Buy Now
Questions 24

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

Buy Now
Questions 25

What is the expected out of the following code of the file named zero_length_existing_file is a zero-length file located inside the working directory?

PCAP-31-03 Question 25

Options:

A.

0

B.

-1

C.

an errno value corresponding to file not found

D.

2

Buy Now
Questions 26

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

Buy Now
Questions 27

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

Buy Now
Questions 28

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:

PCAP-31-03 Question 28

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

Buy Now
Questions 29

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

Options:

A.

open () requires a second argument

B.

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

C.

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

D.

if invoking open () fails, an exception is raised

Buy Now
Questions 30

What is the expected output of the following code?

PCAP-31-03 Question 30

Options:

A.

4

B.

16

C.

an exception is raised

D.

1

Buy Now
Questions 31

What is the expected behavior of the following snippet?

PCAP-31-03 Question 31

It will:

Options:

A.

cause a runtime exception

B.

print 1

C.

print 0 , [1]

D.

print [1J

Buy Now
Questions 32

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

PCAP-31-03 Question 32

Options:

A.

BB

B.

CC

C.

AA

D.

BC

Buy Now
Questions 33

What is the expected behavior of the following code?

PCAP-31-03 Question 33

Options:

A.

it outputs 3

B.

it outputs 1

C.

it outputs 6

D.

it raises an exception

Buy Now
Questions 34

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 '

Buy Now
Questions 35

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

Buy Now
Questions 36

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

PCAP-31-03 Question 36

Options:

A.

isinstance (obj_b,A)

B.

A.VarA == 1

C.

obj_a is obj_aa

D.

B.VarA == 1

Buy Now
Questions 37

What is the expected behavior of the following code?

PCAP-31-03 Question 37

Options:

A.

it outputs 1

B.

it outputs 2

C.

the code is erroneous and it will not execute

D.

it outputs 3

Buy Now
Questions 38

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

Buy Now
Questions 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)

Buy Now
Questions 40

A file name like this one below says mat: (select three answers)

services. cpython-36.pyc

Options:

A.

the interpreter used to generate the file is version 3.6

B.

it has been produced by CPython

C.

it is the 36th version of the file

D.

the file comes from the services . py source file

Buy Now
Questions 41

Which of the following snippets will execute without raising any unhandled exceptions? (Select answers)

A)

PCAP-31-03 Question 41

B)

PCAP-31-03 Question 41

C)

PCAP-31-03 Question 41

D)

PCAP-31-03 Question 41

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Buy Now
Questions 42

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

PCAP-31-03 Question 42

Options:

A.

is instance(obj_b,C)

B.

C._C__VarA == 2

C.

has atr (B, ' get ' )

D.

obj_c.get() == 2

Buy Now
Questions 43

What is the expected behavior of the following code?

PCAP-31-03 Question 43

Options:

A.

it outputs list assignment index out of range

B.

the code is erroneous and it will not execute

C.

it outputs < class ' IndexError ' >

D.

it outputs error

Buy Now
Questions 44

What is the expected behavior of the following code?

PCAP-31-03 Question 44

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]

Buy Now
Questions 45

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

Options:

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

Buy Now
Questions 46

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

Buy Now
Exam Code: PCAP-31-03
Exam Name: Certified Associate in Python Programming
Last Update: May 6, 2026
Questions: 154

PDF + Testing Engine

$63.52  $181.49

Testing Engine

$50.57  $144.49
buy now PCAP-31-03 testing engine

PDF (Q&A)

$43.57  $124.49
buy now PCAP-31-03 pdf