Weekend Sale - 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: dm70dm

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.

len ('' ' '') == 2

B.

len ( ' ' ' 12

34 ' ' ') == 4

C.

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

D.

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

Buy Now
Questions 5

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 6

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 7

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 8

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 8

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 9

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

Buy Now
Questions 10

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

Buy Now
Questions 11

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 12

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

PCAP-31-03 Question 12

Options:

A.

BB

B.

CC

C.

AA

D.

BC

Buy Now
Questions 13

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

Options:

A.

- -

B.

++

C.

<<

D.

>>

Buy Now
Questions 14

What can you deduce from the following statement? (Select two answers)

str = open('file.txt', "rt")

Options:

A.

str is a string read in from the file named file.txt

B.

a newlina character translation will be performed during the reads

C.

if file. txt does not exist, it will be created

D.

the opened file cannot be written with the use of the str variable

Buy Now
Questions 15

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 15

Options:

A.

0

B.

-1

C.

an errno value corresponding to file not found

D.

2

Buy Now
Questions 16

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

PCAP-31-03 Question 16

Options:

A.

1 2

B.

1 2 3

C.

1 3

D.

2 3

Buy Now
Questions 17

What is the expected behavior of the following code?

PCAP-31-03 Question 17

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

Buy Now
Questions 18

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

Buy Now
Questions 19

What is the expected behavior of the following code?

PCAP-31-03 Question 19

Options:

A.

it outputs 6

B.

it outputs 1

C.

it outputs 3

D.

it raises an exception

Buy Now
Questions 20

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 21

What is the expected behavior of the following code?

PCAP-31-03 Question 21

It will:

Options:

A.

print 4321

B.

print

C.

cause a runtime exception

D.

print 1234

Buy Now
Questions 22

What is the expected output of the following code?

PCAP-31-03 Question 22

Options:

A.

4

B.

16

C.

an exception is raised

D.

1

Buy Now
Questions 23

What is the expected behavior of the following snippet?

PCAP-31-03 Question 23

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

Buy Now
Questions 24

What is the expected output of the following code?

PCAP-31-03 Question 24

Options:

A.

3

B.

5

C.

4

D.

an exception is raised

Buy Now
Questions 25

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

PCAP-31-03 Question 25

Options:

A.

a ( ) == 4

B.

a is not None

C.

b ( ) == 4

D.

a ! = b

Buy Now
Questions 26

What is the expected behavior of the following code?

x = 8 ** (1/3)

y = 2. if x < 2.3 else 3.

print(y)

Options:

A.

it outputs 2.0

B.

it outputs 2. 5

C.

the code is erroneus and it will not execute

D.

it outputs 3.0

Buy Now
Questions 27

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

PCAP-31-03 Question 27

Options:

A.

10

B.

the variable becomes unavailable

C.

11

D.

9

Buy Now
Questions 28

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

A)

PCAP-31-03 Question 28

B)

PCAP-31-03 Question 28

C)

PCAP-31-03 Question 28

D)

PCAP-31-03 Question 28

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Buy Now
Questions 29

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 29

Options:

A.

s.split ()

B.

split (s, "˜ "˜)

C.

s.split ("˜ "˜)

D.

split (s)

Buy Now
Questions 30

What is the expected behavior of the following code?

PCAP-31-03 Question 30

Options:

A.

it raises an exception

B.

it outputs True

C.

it outputs False

D.

it outputs nothing

Buy Now
Questions 31

What is the expected output of the following snippet?

PCAP-31-03 Question 31

Options:

A.

abc

B.

The code will cause a runtime exception

C.

ABC

D.

123

Buy Now
Questions 32

What is the expected behavior of the following code?

PCAP-31-03 Question 32

Options:

A.

it outputs False

B.

it outputs True

C.

it raises an exception

D.

it outputs nothing

Buy Now
Questions 33

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)

PCAP-31-03 Question 33

Options:

A.

put self.store(1])

B.

self put stire(1])

C.

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

D.

self .put (self.store[1])

Buy Now
Questions 34

What is the expected behavior of the following code?

PCAP-31-03 Question 34

Options:

A.

it outputs 'None'

B.

it outputs 3

C.

it raises an exception

D.

it outputs 0

Buy Now
Questions 35

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

PCAP-31-03 Question 35

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

Buy Now
Questions 36

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 37

What is the output of the following piece of code?

PCAP-31-03 Question 37

Options:

A.

ant'bat'camel

B.

ant"bat"camel

C.

antbatcamel

D.

ant bat camel

Buy Now
Questions 38

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

PCAP-31-03 Question 38

Options:

A.

a is not None

B.

a ! =b

C.

b () ==4

D.

a () == 4

Buy Now
Questions 39

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

Buy Now
Questions 40

What is the expected behavior of the following code?

PCAP-31-03 Question 40

Options:

A.

it outputs 2

B.

it raises an exception

C.

it outputs 3

D.

it outputs 5

Buy Now
Questions 41

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 42

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

PCAP-31-03 Question 42

Options:

A.

BB

B.

CC

C.

AA

D.

BC

Buy Now
Questions 43

Which one of the platform module functions should be used to determine the underlying platform name?

Options:

A.

platform.uname ()

B.

platform.platform ()

C.

platform.python_version()

D.

platform.processor()

Buy Now
Questions 44

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 45

Which of the following lambda function definitions are correct? (Select two answers)

Options:

A.

lambda X : None

B.

lambda : 3,1415

C.

lambda x : def fun(x): return x

D.

lambda lambda: lambda * lambda

Buy Now
Questions 46

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 46

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
Exam Code: PCAP-31-03
Exam Name: Certified Associate in Python Programming
Last Update: Oct 18, 2025
Questions: 154

PDF + Testing Engine

$49.5  $164.99

Testing Engine

$37.5  $124.99
buy now PCAP-31-03 testing engine

PDF (Q&A)

$31.5  $104.99
buy now PCAP-31-03 pdf
dumpsmate guaranteed to pass
24/7 Customer Support

DumpsMate's team of experts is always available to respond your queries on exam preparation. Get professional answers on any topic of the certification syllabus. Our experts will thoroughly satisfy you.

Site Secure

mcafee secure

TESTED 18 Oct 2025