Winter Special Sale - Limited Time 60% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: 575363r9

Welcome To DumpsPedia

PCAP-31-03 Sample Questions Answers

Questions 4

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)

Buy Now
Questions 5

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)

Buy Now
Questions 6

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

Buy Now
Questions 7

What is the expected behavior of the following code?

Options:

A.

It outputs False

B.

It outputs nothing

C.

It outputs True

D.

It raises an exception

Buy Now
Questions 8

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 9

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 10

What is the expected behavior of the following code?

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 11

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

A)

B)

C)

D)

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Buy Now
Questions 12

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 13

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 14

Which of the following literals reflect the value given as 34.23? (select two answers)

Options:

A.

.3423e2

B.

3423e-2

C.

.3423e-2

D.

3423e2

Buy Now
Questions 15

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

Options:

A.

if a real-life object can be described with a set of adjectives, they may reflect a Python object method

B.

the same class can be used many times to build a number of objects

C.

each object of the same class can have a different set of methods

D.

a subclass is usually more specialized than its superclass

Buy Now
Questions 16

What is the expected behavior of the following code?

x - 3 % 1

y -1 if x > else 0

print (y)

Options:

A.

it outputs -1

B.

the code is erroneous and it will not execute

C.

it outputs 1

D.

it outputs 0

Buy Now
Questions 17

What is the expected output of the following code?

Options:

A.

2

B.

3

C.

4

D.

an exception is raised

Buy Now
Questions 18

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 19

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 20

What is the expected output of the following snippet?

Options:

A.

1

B.

4

C.

2

D.

3

Buy Now
Questions 21

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 22

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 23

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

Buy Now
Questions 24

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 25

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 26

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

Buy Now
Questions 27

What is the expected output of the following code?

Options:

A.

a

B.

an exception is raised

C.

b

D.

c

Buy Now
Questions 28

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

Options:

A.

- -

B.

++

C.

<<

D.

>>

Buy Now
Questions 29

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 30

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 31

What is the expected output of the following snippet?

Options:

A.

True lower

B.

True upper

C.

False upper

D.

False lower

Buy Now
Questions 32

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

Buy Now
Questions 33

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 34

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

Options:

A.

2 2

B.

1 3

C.

1 2 3

D.

2 2 3

Buy Now
Questions 35

The following expression

1+-2

is:

Options:

A.

equal to 1

B.

invalid

C.

equal to 2

D.

equal to -1

Buy Now
Questions 36

What is the expected output of the following code?

Options:

A.

21

B.

2

C.

3

D.

12

Buy Now
Questions 37

What is the expected behavior of the following code?

Options:

A.

It outputs 123

B.

it raises an exception

C.

it outputs 321

D.

it outputs 6

Buy Now
Questions 38

Executing the following snippet

will cause the dct:

Options:

A.

to hold two keys named ‘pi’ linked to 3.14 and 3.1415 respectively

B.

to hold two key named ‘pi’ linked to 3.14 and 3.1415

C.

to hold one key named ‘pi’ linked to 3.1415

D.

to hold two keys named ‘pi’ linked to 3.1415

Buy Now
Questions 39

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

Buy Now
Questions 40

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 41

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 42

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

Buy Now
Questions 43

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

Options:

A.

BB

B.

CC

C.

AA

D.

BC

Buy Now
Questions 44

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
Exam Code: PCAP-31-03
Exam Name: Certified Associate in Python Programming
Last Update: Nov 13, 2024
Questions: 147
$64  $159.99
$48  $119.99
$40  $99.99
buy now PCAP-31-03