New Year Sale Special Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: xmas50

Python Institute PCAP-31-03 - Certified Associate in Python Programming

Page: 4 / 5
Total 154 questions

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?

A.

print (get(self))

B.

print (self.get())

C.

print (get())

D.

print (self.get (val))

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)

A.

put (self.prop + vaI)

B.

self.put (self.get ( ) + vaI)

C.

self.put (get ( ) + vaI)

D.

self.put (self.prop + vaI)

The following expression

1+-2

is:

A.

equal to 1

B.

invalid

C.

equal to 2

D.

equal to -1

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

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

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

What is the expected behavior of the following snippet?

It will:

A.

cause a runtime exception

B.

print 1

C.

print 0 , [1]

D.

print [1J

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

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

What is the expected behavior of the following code?

A.

it outputs error

B.

it outputs list assignment index out of range

C.

the code is erroneous and it will not execute

D.

it outputs

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)

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

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

(Select two answers.)

A.

a == b

B.

b {1} == 4

C.

a is not None

D.

a (2) == 4

A variable stored separately in every object is called:

A.

there are no such variables, all variables are shared among objects

B.

a class variable

C.

an object variable

D.

an instance variable