Weekend Special Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: netbudy65

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

Questions 4

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'

Buy Now
Questions 5

What is the expected output of the following snippet?

PCAP-31-03 Question 5

Options:

A.

3

B.

1

C.

2

D.

the code is erroneous

Buy Now
Questions 6

What is the expected behavior of the following code?

PCAP-31-03 Question 6

Options:

A.

it outputs False

B.

it outputs True

C.

it raises an exception

D.

it outputs nothing

Buy Now
Questions 7

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 7

Options:

A.

str (Object) = 'Object1

B.

Class A.__module__ == ' main__'

C.

len (ClassB.__bases__) == 2

D.

__name__== '__main__'

Buy Now
Questions 8

What is the expected behavior of the following code?

PCAP-31-03 Question 8

It will:

Options:

A.

print 0

B.

cause a runtime exception

C.

prints 3

D.

print an empty line

Buy Now
Questions 9

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 10

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

A)

PCAP-31-03 Question 10

B)

PCAP-31-03 Question 10

C)

PCAP-31-03 Question 10

D)

PCAP-31-03 Question 10

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Buy Now
Questions 11

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

Buy Now
Questions 12

Select the valid fun () invocations:

(select two answers)

def fun (a, b=0):

return a*b

Options:

A.

fun(b=1)

B.

fun (a=0)

C.

fun(b=1, 0)

D.

fun (1)

Buy Now
Questions 13

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

A)

PCAP-31-03 Question 13

B)

PCAP-31-03 Question 13

C)

PCAP-31-03 Question 13

D)

PCAP-31-03 Question 13

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Buy Now
Questions 14

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 14

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 15

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

Buy Now
Questions 16

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 16

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 17

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

Options:

A.

_upper_

B.

_bases_

C.

_ancestors_

D.

_super_

Buy Now
Questions 18

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

PCAP-31-03 Question 18

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

Buy Now
Questions 19

How many lines does the following snippet output?

PCAP-31-03 Question 19

Options:

A.

three

B.

one

C.

two

D.

four

Buy Now
Questions 20

What is the expected behavior of the following code?

PCAP-31-03 Question 20

Options:

A.

It outputs 123

B.

it raises an exception

C.

it outputs 321

D.

it outputs 6

Buy Now
Questions 21

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

PCAP-31-03 Question 21

Options:

A.

2 2

B.

1 3

C.

1 2 3

D.

2 2 3

Buy Now
Questions 22

What is the expected behavior of the following code?

PCAP-31-03 Question 22

It will:

Options:

A.

print 4321

B.

print

C.

cause a runtime exception

D.

print 1234

Buy Now
Questions 23

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 23

PCAP-31-03 Question 23

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 24

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 24

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 25

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

PCAP-31-03 Question 25

Options:

A.

len(a) == len (b)

B.

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

C.

a [0] == b [0]

D.

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

Buy Now
Questions 26

What is the expected output of the following code?

PCAP-31-03 Question 26

Options:

A.

2

B.

3

C.

4

D.

an exception is raised

Buy Now
Questions 27

Assuming that the math module has been successfully imported, which of the following expressions evaluate to True? (Select two answers)

Options:

A.

math. hypot (3,4) == math.sqrt (25)

B.

math. hypot (2,5) == math.truec (2.5)

C.

math. hypot (2,5) == math.true (2.5)

D.

math. cell (2,5) == math.floor (2.5)

Buy Now
Questions 28

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

Options:

A.

len('\'•) == 1

B.

len("""

""") == o

C.

chr(ordCA') + 1) == 'B'

D.

ord("Z") - ord("z") -- ord("0")

Buy Now
Questions 29

What is the expected behavior of the following code?

PCAP-31-03 Question 29

Options:

A.

it outputs 2

B.

the code is erroneous and it will not execute

C.

it outputs 1

D.

it outputs 3

Buy Now
Questions 30

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

Options:

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.

Buy Now
Questions 31

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

Options:

A.

two

B.

zero

C.

one

D.

three

Buy Now
Questions 32

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)

Options:

A.

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

B.

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

C.

dir={Mom:5551234567, Dad:5557654321}

D.

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

Buy Now
Questions 33

What is the expected behavior of the following snippet?

PCAP-31-03 Question 33

It will:

Options:

A.

cause a runtime exception

B.

print 1

C.

print 0 , [1]

D.

print [1J

Buy Now
Questions 34

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 34

Options:

A.

str(Object) == 'Object'

B.

_name == _main_'

C.

ClassA. _module_ == 'ClassA'

D.

len(ClassB.__bases__) == 1

Buy Now
Questions 35

The simplest possible class definition in Python can be expressed as:

Options:

A.

class X:

B.

class X:

pass

C.

class X:

return

D.

class X: {}

Buy Now
Questions 36

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
Questions 37

What is the expected output of the following code?

PCAP-31-03 Question 37

Options:

A.

4

B.

16

C.

an exception is raised

D.

1

Buy Now
Questions 38

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

Buy Now
Questions 39

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

Buy Now
Questions 40

What is the expected output of the following snippet?

PCAP-31-03 Question 40

Options:

A.

True lower

B.

True upper

C.

False upper

D.

False lower

Buy Now
Questions 41

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 42

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

Options:

A.

for

B.

True

C.

true

D.

For

Buy Now
Questions 43

What is the expected behavior of the following code?

PCAP-31-03 Question 43

Options:

A.

it raises an exception

B.

it outputs True

C.

it outputs False

D.

it outputs nothing

Buy Now
Questions 44

What is the expected behavior of the following code?

PCAP-31-03 Question 44

Options:

A.

it outputs 1

B.

it outputs 0

C.

it raises an exception

D.

it outputs 2

Buy Now
Questions 45

What is the expected behavior of the following code?

PCAP-31-03 Question 45

Options:

A.

It outputs 3.

B.

It outputs 1.

C.

It outputs 6.

D.

It raises an exception

Buy Now
Questions 46

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

PCAP-31-03 Question 46

Options:

A.

isinstance (obj_b,A)

B.

A.VarA == 1

C.

obj_a is obj_aa

D.

B.VarA == 1

Buy Now
Exam Code: PCAP-31-03
Exam Name: Certified Associate in Python Programming
Last Update: Oct 15, 2025
Questions: 154

PDF + Testing Engine

$134.99

Testing Engine

$99.99

PDF (Q&A)

$84.99