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

Home > Python Institute > PCAP > PCAP-31-03

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

Question # 4

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

Full Access
Question # 5

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

A.

'in not' in 'not'

B.

'in' in 'Thames'

C.

't' . upper ( ) in 'Thames'

D.

'in' in 'in'

Full Access
Question # 6

What is the expected behavior of the following code?

x - 3 % 1

y -1 if x > else 0

print (y)

A.

it outputs -1

B.

the code is erroneous and it will not execute

C.

it outputs 1

D.

it outputs 0

Full Access
Question # 7

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

Full Access
Question # 8

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?

A.

0

B.

-1

C.

an errno value corresponding to file not found

D.

2

Full Access
Question # 9

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

A.

lambda X : None

B.

lambda : 3,1415

C.

lambda x : def fun(x): return x

D.

lambda lambda: lambda * lambda

Full Access
Question # 10

What can you do if you don't like a long package path tike this one0 import alpha.beta.gamma.delta.epsiIon.zeta

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

Full Access
Question # 11

The__bases__property contains:

A.

base class locations (addr)

B.

base class objects (class)

C.

base class names (str)

D.

base class ids (int)

Full Access
Question # 12

What is the expected behavior of the following code?

A.

it outputs 1

B.

it outputs 2

C.

the code is erroneous and it will not execute

D.

it outputs 3

Full Access
Question # 13

What is the expected output of the following code?

A.

abcef

B.

The program will cause a runtime exception error

C.

acdef

D.

abdef

Full Access
Question # 14

What is the expected behavior of the following code?

A.

it outputs -2

B.

it outputs 2. 0

C.

it outputs 0. 0

D.

the code is erroneous and it will not execute

Full Access
Question # 15

A file name like this one below says mat: (select three answers)

services. cpython-36.pyc

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

Full Access
Question # 16

You need data which can act as a simple telephone directory. You can obtain it with the following clauses (choose two relevant variants; assume that no other items have been created before)

A.

dir={'Mom':5551234567, 'Dad':5557654321>

B.

dir={'Mom':'5551234567', * Dad':'5557654321'}

C.

dir={Mom:5551234567, Dad:5557654321}

D.

dir={Mom:'5551234567', Dad:'5557654321'}

Full Access
Question # 17

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

A.

\e is an escape sequence used to mark the end of lines

B.

ASCII is synonymous with UTF-8

C.

II in ASCII stands for Information Interchange

D.

a code point is a number assigned to a given character

Full Access
Question # 18

Assuming that the code below has been placed inside a file named code.py and executed successfully, which of the following expressions evaluate to True? (Select two answers)

A.

str(Object) == 'Object'

B.

_name == _main_'

C.

ClassA. _module_ == 'ClassA'

D.

len(ClassB.__bases__) == 1

Full Access
Question # 19

What is the expected behavior of the following code?

It will:

A.

print 4321

B.

print

C.

cause a runtime exception

D.

print 1234

Full Access
Question # 20

Assuming that the V variable holds an integer value to 2, which of the following operators should be used instead of OPER to make the expression equal to 1?

V OPER 1 -

A.

<<<

B.

>>>

C.

>>

D.

<<

Full Access
Question # 21

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

A.

encapsulation allows you to protect some data from uncontrolled access

B.

the arrows on a class diagram are always directed from a superclass towards its subclass

C.

inheritance is the relation between a superclass and a subclass

D.

an object is a recipe for a class

Full Access
Question # 22

What is the expected output of the following code?

A.

21

B.

2

C.

3

D.

12

Full Access