Black Friday Biggest Discount Flat 70% Offer - Ends in 0d 00h 00m 00s - Coupon code: 70diswrap

Python Institute PCAP-31-03 Dumps

Page: 1 / 15
Total 145 questions

Certified Associate in Python Programming Questions and Answers

Question 1

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

Options:

A.

11 == '011'

B.

3 * 'a' < 'a' * 2

C.

'abc' .upper () < 'abc'

D.

'1' + '2' * 2 !=2 '12'

Question 2

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

Question 3

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

Options:

A.

.

B.

&

C.

_

D.

+

Question 4

What is the expected behavior of the following code?

as

It will:

Options:

A.

print 4321

B.

print

C.

cause a runtime exception

D.

print 1234

Question 5

What is the expected behavior of the following code?

as

Options:

A.

it outputs 2

B.

it raises an exception

C.

it outputs 3

D.

it outputs 5

Question 6

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?

as

Options:

A.

print (get(self))

B.

print (self.get())

C.

print (get())

D.

print (self.get (val))

Question 7

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

Question 8

Which of the equations are True? (Select two answers)

Options:

A.

chr (ord (x)) = = x

B.

ord (ord (x)) = = x

C.

chr (chr (x)) = = x

D.

ord (chr (x)) = = x

Question 9

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

Question 10

If you want to access an exception object's components and store them in an object called e, you have to use the following form of exception statement

Options:

A.

except Exception(e):

B.

except e=Exception:

C.

except Exception as e:

D.

such an action is not possible in Python

Question 11

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)

Question 12

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

Question 13

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

Question 14

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

Question 15

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

Options:

A.

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

B.

the second open () argument is optional

C.

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

D.

if invoking open () fails, the value None is returned

Question 16

What is the expected behavior of the following code?

as

Options:

A.

it outputs -2

B.

it outputs 2. 0

C.

it outputs 0. 0

D.

the code is erroneous and it will not execute

Question 17

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

Question 18

Executing the following snippet

as

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

Question 19

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

as

Options:

A.

BB

B.

CC

C.

AA

D.

BC

Question 20

What is the expected behavior of the following code?

as

Options:

A.

it raises an exception

B.

it outputs True

C.

it outputs False

D.

it outputs nothing

Question 21

You are going to read 16 bytes from a binary file into a bytearray called data. Which lines would you use? (Select two answers)

Options:

A.

data = bytearray (16) bf.readinto (data)

B.

data = binfile.read (bytearray (16))

C.

bf. readinto (data = bytearray (16))

D.

data = bytearray (binfile.read (16))

Page: 1 / 15
Total 145 questions