Black Friday Special Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: 70special

Python Institute PCAP-31-03 Certified Associate in Python Programming Exam Practice Test

Page: 1 / 15
Total 145 questions

Certified Associate in Python Programming Questions and Answers

Testing Engine

  • Product Type: Testing Engine
$37.5  $124.99

PDF Study Guide

  • Product Type: PDF Study Guide
$33  $109.99
Question 1

What can you do if you don’t like a long package path like this one?

Options:

A.

you can make an alias for the name using the alias 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 the as keyword

Question 2

Assuming that String is six or more letters long, the following slice

String[1:-2]

is shorter than the original string by:

Options:

A.

four chars

B.

three chars

C.

one char

D.

two chars

Question 3

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

Question 4

What is the expected behavior of the following snippet?

It will:

Options:

A.

cause a runtime exception

B.

print 1

C.

print 0 , [1]

D.

print [1J

Question 5

What is the expected output of the following code?

Options:

A.

True

B.

0

C.

False

D.

None

Question 6

How many elements will the list2 list contain after execution of the following snippet?

list1 = [False for i in range (1, 10) ]

list2 = list1 [-1:1:-1]

Options:

A.

zero

B.

five

C.

seven

D.

three

Question 7

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

Question 8

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)

Options:

A.

str(Object) == 'Object'

B.

_name == _main_'

C.

ClassA. _module_ == 'ClassA'

D.

len(ClassB.__bases__) == 1

Question 9

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

Question 10

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

Question 11

Assuming that the following code has been executed successfully, select the expressions which evaluate to True (Select two answers.)

Options:

A.

a is not None

B.

a ! =b

C.

b () ==4

D.

a () == 4

Question 12

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)

Options:

A.

str (Object) = 'Object1

B.

Class A.__module__ == ' main__'

C.

len (ClassB.__bases__) == 2

D.

__name__== '__main__'

Question 13

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

Question 14

Which of the following words can be used as a variable name? (Select two valid names)

Options:

A.

for

B.

True

C.

true

D.

For

Question 15

With regards to the directory structure below, select the proper forms of the directives in order to import module_c. (Select two answers)

Options:

A.

from pypack.upper.lower import module_c

B.

import pypack.upper.lower.module_c

C.

import upper.module_c

D.

import upper.lower.module_c

Question 16

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

Question 17

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

Question 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 :

Question 19

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

Options:

A.

- -

B.

++

C.

<<

D.

>>

Question 20

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

Question 21

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 22

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

Page: 1 / 15
Total 145 questions