top of page

Certified Associate in Python Programming - PCAP Exam Answers

Psst, You can use CTRL+F to search for question on site. Good luck!

Certified Associate in Python Programming - PCAP Exam Answers


Question 1

What will be the value of the i variable when the while e loop finishes its execution?

A. 1

B. 0

C. 2

D. the variable becomes unavailable

Certified Associate in Python Programming Question 1 answers

Question 2

And operator able to perform bitwise shifts is coded as (Choose two.)

A. --

B. ++

C. <<

D. >>

Question 3

Certified Associate in Python Programming Question 3 answers

What will the value of the i variable be when the following loop finishes its execution?

A. 10

B. the variable becomes unavailable

C. 11

D. 9


Question 4

The following expression -

is:

A. equal to 1

B. invalid

C. equal to 2

D. equal to -1


Certified Associate in Python Programming Question 4 answers

Question 5

A compiler is a program designed to (Choose two.)

A. rearrange the source code to make it clearer

B. check the source code in order to see of it's correct Most Voted

C. execute the source code

D. translate the source code into machine code Most Voted


Question 6

What is the output of the following piece of code?

Certified Associate in Python Programming Question 6 answers

A. ant' bat' camel

B. ant"bat"camel

C. antbatcamel

D. print (a, b, c, sep= ' ג€ ')


Certified Associate in Python Programming Question 6 answers

Question 7

What is the expected output of the following snippet?

Certified Associate in Python Programming Question 7 answers

A. the code is erroneous

B. 3

C. 7

D. 15


Question 8

How many lines does the following snippet output?

Certified Associate in Python Programming Question 8 answers

A. three

B. one

C. two

D. four


Question 9

Which of the following literals reflect the value given as 34.23? (Choose two.)

A. .3423e2

B. 3423e-2

C. .3423e-2

D. 3423e2

Question 10

What is the expected output of the following snippet?

Certified Associate in Python Programming Question 10 answers

A. 3

B. 1

C. 2

D. the code is erroneous


Question 11

Assuming that the following snippet has been successfully executed, which of the equations are True? (Choose two.)

Certified Associate in Python Programming Question 11 answers

A. len(a) == len (b)

B. b [0] +1 ==a [0]

C. a [0] == b [0]

D. a [0] + 1 ==b [0]


Question 12

Assuming that the following snippet has been successfully executed, which of the equations are False? (Choose two.)

Certified Associate in Python Programming Question 12 answers

A. len(a)== len (b)

B. a [0]-1 ==b [0]

C. a [0]== b [0]

D. b [0] - 1 ==a [0]


Question 13

Which of the following statements are true? (Choose two.)

A. Python strings are actually lists

B. Python strings can be concatenated

C. Python strings can be sliced like lists

D. Python strings are mutable


Question 14

Which of the following sentences are true? (Choose two.)

A. Lists may not be stored inside tuples

B. Tuples may be stored inside lists

C. Tuples may not be stored inside tuples

D. Lists may be stored inside lists


Question 15

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

is shorter than the original string by:

A. four chars

B. three chars

C. one char

D. two chars


Question 16

What is the expected output of the following snippet?

Certified Associate in Python Programming Question 16 answers

A. 1

B. 4

C. 2

D. 3


Question 17

What is the expected output of the following snippet?

Certified Associate in Python Programming Question 17 answers

A. abc

B. The code will cause a runtime exception

C. ABC

D. 123


Question 18

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

Certified Associate in Python Programming Question 18 answers

A. zero

B. five

C. seven

D. three


Question 19

What would you used instead of XXX if you want to check weather a certain 'key' exists in a dictionary called dict? (Choose two.)

Certified Associate in Python Programming Question 19 answers

A. 'key' in dict

B. dict ['key'] != None

C. dict.exists ('key')

D. 'key' in dict.keys ( )


Question 20

You need data which can act as a simple telephone directory. You can obtain it with the following clauses (Choose two.) (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'}


Question 21

Can a module run like regular code?

A. yes, and it can differentiate its behavior between the regular launch and import

B. it depends on the Python version

C. yes, but in cannot differentiate its behavior between the regular launch and import

D. no, it is not possible; a module can be imported, not run


Question 22

Select the valid fun () invocations:

(Choose two.)

Certified Associate in Python Programming Question 22 answers

A. fun (b=1)

B. fun (a=0)

C. fun (b=1, 0)

D. fun (1)


Question 23

A file name like this one below says that:

(Choose three.)

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 36 version of the file

D. the file comes from the services.py source file


Question 24

What is the expected behavior of the following snippet?

Certified Associate in Python Programming Question 24 answers

It will:

A. cause a runtime exception

B. print 1

C. print 0, [1]

D. print [1]


Question 25

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

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 26

What is the expected output of the following code?

Certified Associate in Python Programming Question 26 answers

A. abcef

B. The program will cause a runtime exception/error

C. acdef

D. abdef


Question 27

What is the expected output of the following code?

Certified Associate in Python Programming Question 27 answers

A. 21

B. 2

C. 3

D. 12


Question 28

What is the expected behavior of the following snippet?

Certified Associate in Python Programming Question 28 answers

It will:

A. cause a runtime exception on line 02

B. cause a runtime exception on line 01

C. cause a runtime exception on line 03

D. print 3


Question 29

What is the expected behavior of the following code?

Certified Associate in Python Programming Question 29 answers

It will:

A. print 4321

B. print <generator object f at (some hex digits)>

C. cause a runtime exception

D. print 1234


Question 30

If you need a function that does nothing, what would you use instead of XXX? (Choose two.)

Certified Associate in Python Programming Question 30 answers

A. pass

B. return

C. exit

D. None


Certified Associate in Python Programming - PCAP Exam Answers


Question 31

Is it possible to safely check if a class/object has a certain attribute?

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


Question 32

The first parameter of each method:

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 33

The simplest possible class definition in Python can be expressed as:

A. class X:

B. class X: pass

C. class X: return

D. class X: { }


Question 34

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:

A. except Exception (e) :

B. except e= Exception :

C. except Exception as e:

D. such an action is not possible in Python


Question 35

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


Question 36

There is a stream named s open for writing. What option will you select to write a line to the stream?

A. s. write (ג€Hello\nג€)

B. write (s, ג€Helloג€)

C. s.writeln (ג€Helloג€)

D. s. writeline (ג€Helloג€)


Question 37

You are going to read just one character from a stream called s. Which statement would you use?

A. ch = read (s, 1)

B. ch= s.input (1)

C. ch= input (s, 1)

D. ch= s.read (1)


Question 38

What can you deduce from the following statement? (Choose two.)

A. str is a string read in from the file named file.txt

B. a newline 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 39

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

Certified Associate in Python Programming Question 39 answers

A. BB

B. CC

C. AA

D. BC


Question 40

Python's built in function named open () tries to open a file and returns:

A. an integer value identifying an opened file

B. an error code (0 means success)

C. a stream object

D. always None


Question 41

Which of the following words can be used as a variable name? (Choose two.)

A. for

B. True

C. true

D. For


Question 42

Python strings can be `glued` together using the operator:

A. .

B. &

C. _

D. +


Question 43

A keyword (Choose two.)

A. can be used as an identifier

B. is defined by Python's lexis

C. is also known as a reserved word

D. cannot be used in the user's code


Question 44

How many stars (*) does the snippet print?

Certified Associate in Python Programming Question 44 answers

A. the code is erroneous

B. five

C. four

D. two


Question 45

Which line can be used instead of the comment to cause the snippet to produce the following expected output? (Choose two.)

Certified Associate in Python Programming Question 45 answers

Expected output:

1 2 3

Code:

A. c, b, a = b, a, c

B. c, b, a = a, c, b

C. a, b, c = c, a, b

D. a, b, c = a, b, c


Question 46

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


Question 47

How many stars (*) does the following snippet print?

Certified Associate in Python Programming Question 47 answers

A. the code is erroneous

B. five

C. three

D. four


Question 48

UNICODE is:

A. the name of an operating system

B. a standard for encoding and handling texts

C. the name of a programming language

D. the name of a text processor


Question 49

What is the expected output of the following snippet?

Certified Associate in Python Programming Question 49 answers

A. *- **-**-**-*

B. *-**-**-**-**-**-**-**-*

C. *-*

D. *-**-*


Question 50

Which of the listed actions can be applied to the following tuple? (Choose two.)

Certified Associate in Python Programming Question 50 answers

A. tup [:]

B. tup.append (0)

C. tup [0]

D. del tup


Question 51

Executing the following snippet -

Certified Associate in Python Programming Question 51 answers

will cause the dct:

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 52

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

Certified Associate in Python Programming Question 52 answers

A. two

B. zero

C. one

D. three


Question 53

Which of the equations are True? (Choose two.)

A. chr (ord (x)) = = x

B. ord (ord (x)) = = x

C. chr (chr (x)) = = x

D. ord (chr (x)) = = x


Question 54

If you want to transform a string into a list of words, what invocation would you use? (Choose two.)

Expected output:

Certified Associate in Python Programming Question 54

Code:

Certified Associate in Python Programming Question 54 answers

A. s.split ()

B. split (s, ' ')

C. s.split (' ')

D. split (s)


Question 55

Assuming that 1 -

is a four-element list is there any difference between these two statements?

Certified Associate in Python Programming Question 55 answers

A. yes, there is, the first line empties the list, the second line deletes the list as a whole

B. yes, there is, the first line deletes the list as a whole, the second line just empties the list

C. no, there is no difference

D. yes, there is, the first line deletes the list as a whole, the second line removes all the elements except the first one


Question 56

What should you put instead of XXX to print out the module name?

Certified Associate in Python Programming Question 56 answers

A. main

B. _main_

C. __main__

D. ___main___


Question 57

Files with the suffix .pyc contain:

A. Python 4 source code

B. backups

C. temporary data

D. semi-compiled Python code


Question 58

Package source directories/folders can be:

A. converted into the so-called pypck format

B. packed as a ZIP file and distributed as one file

C. rebuilt to a flat form and distributed as one directory/folder

D. removed as Python compiles them into an internal portable format


Question 59

What can you deduce from the line below? (Choose two.)

Certified Associate in Python Programming Question 59 answers

A. import a.b.c should be placed before that line

B. f () is located in subpackage c of subpackage b of package a

C. the line is incorrect

D. the function being invoked is called a.b.c.f ()


Question 60

A two-parameter lambda function raising its first parameter to the power of the second parameter should be declared as:

A. lambda (x, y) = x ** y

B. lambda (x, y): x ** y

C. def lambda (x, y): return x ** y

D. lambda x, y: x ** y


Question 61

What is the expected output of the following code?

Certified Associate in Python Programming Question 61 answers

A. 21

B. 12

C. 3

D. none


Question 62

A method for passing the arguments used by the following snippet is called:

Certified Associate in Python Programming Question 62 answers

A. sequential

B. named

C. positional

D. keyword


Question 63

What is the expected behavior of the following code?

Certified Associate in Python Programming Question 63 answers

It will -

A. print 2 1

B. print 1 2

C. cause a runtime exception

D. print <generator object f at (some hex digits)>


Question 64

What is the expected output of the following code?

Certified Associate in Python Programming Question 64 answers

A. 2

B. The code will cause a runtime exception

C. 1

D. 3

Question 65

What is the expected behavior of the following code?

Certified Associate in Python Programming Question 65 answers

It will:

A. print 0

B. cause a runtime exception

C. prints 3

D. print an empty line


Question 66

If any of a class's components has a name that starts with two underscores (___), then:

A. the class component's name will be mangled

B. the class component has to be an instance variable

C. the class component has to be a class variable

D. the class component has to be a method


Question 67

If you need to serve two different exceptions called Ex1 and Ex2 in one except branch, you can write:

A. except Ex1 Ex2:

B. except (ex1, Ex2):

C. except Ex1, Ex2:

D. except Ex1+Ex2:


Question 68

A function called issubclass (c1, c2) is able to check if:

A. c1 and c2 are both subclasses of the same superclass

B. c2 is a subclass of c1

C. c1 is a subclass of c2

D. c1 and c2 are not subclasses of the same superclass


Certified Associate in Python Programming - PCAP Exam Answers

bottom of page