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

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

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

Buy Now
Questions 5

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 6

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

Buy Now
Questions 7

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 8

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?

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 9

Which of the following invocations are valid? (Select two answers)

Options:

A.

sorted ("python'')

B.

"python" .sort ( )

C.

sort" ("python")

D.

"python' ,find (" ")

Buy Now
Questions 10

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 11

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

Buy Now
Questions 12

What is the expected behavior of the following code?

Options:

A.

it outputs 2

B.

the code is erroneous and it will not execute

C.

it outputs 3

D.

it outputs :

Buy Now
Questions 13

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 14

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

Buy Now
Questions 15

What is the expected output of the following code?

Options:

A.

21

B.

2

C.

3

D.

12

Buy Now
Questions 16

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

A)

B)

C)

D)

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Buy Now
Questions 17

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

Buy Now
Questions 18

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 19

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 20

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 21

The__bases__property contains:

Options:

A.

base class locations (addr)

B.

base class objects (class)

C.

base class names (str)

D.

base class ids (int)

Buy Now
Questions 22

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

Buy Now
Questions 23

A method for passing the arguments used by the following snippet is called:

Options:

A.

sequential

B.

named

C.

positional

D.

keyword

Buy Now
Questions 24

Assuming that the following code has been executed successfully, select the expressions which evaluate to true.

(Select two answers.)

Options:

A.

a == b

B.

b {1} == 4

C.

a is not None

D.

a (2) == 4

Buy Now
Questions 25

What is the expected output of the following code?

Options:

A.

True

B.

0

C.

False

D.

None

Buy Now
Questions 26

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

Buy Now
Questions 27

The following expression

1+-2

is:

Options:

A.

equal to 1

B.

invalid

C.

equal to 2

D.

equal to -1

Buy Now
Questions 28

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

Buy Now
Questions 29

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

Buy Now
Questions 30

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

Options:

A.

a code point is a point inside the code when execution stops immediately

B.

an escape sequence can be recognized by the # sign put in front of it.

C.

UTF-8 is one of the ways of representing UNICODE code points.

D.

ASCII is the name of a character coding standard

Buy Now
Questions 31

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

Buy Now
Questions 32

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

Buy Now
Questions 33

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 34

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

Buy Now
Questions 35

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]

Buy Now
Questions 36

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 37

Which of the following expressions evaluate to True?

A)

B)

C)

D)

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Buy Now
Questions 38

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

Buy Now
Questions 39

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 40

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

Options:

A.

.

B.

&

C.

_

D.

+

Buy Now
Questions 41

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)

Buy Now
Questions 42

What is the expected behavior of the following code?

Options:

A.

it outputs False

B.

it outputs True

C.

it raises an exception

D.

it outputs nothing

Buy Now
Questions 43

Files with the suffix .pyc contain:

Options:

A.

Python 4 source code

B.

backups

C.

temporary data

D.

semi-compiled Python code

Buy Now
Questions 44

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

Buy Now
Questions 45

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 46

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

PCAP-31-03 PDF

$25.5  $84.99
PCAP-31-03 Engine

PCAP-31-03 Testing Engine

$30  $99.99
PCAP-31-03 PDF + Engine

PCAP-31-03 PDF + Testing Engine

$40.5  $134.99