Big 11.11 Sale 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: save70

Free and Premium Python Institute PCAP-31-03 Dumps Questions Answers

Page: 1 / 12
Total 154 questions

Certified Associate in Python Programming Questions and Answers

Question 1

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

Buy Now
Question 2

What is the expected output of the following snippet?

Options:

A.

True lower

B.

True upper

C.

False upper

D.

False lower

Question 3

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

Options:

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

Question 4

What is the expected output of the following code?

Options:

A.

4

B.

16

C.

an exception is raised

D.

1

Question 5

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

def idler ( ):

XXX

Options:

A.

pass

B.

return

C.

exit

D.

None

Question 6

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

Options:

A.

a code point is a point inside the code when execution stops immediately

B.

an escape sequence can be recognized by the # sign put in front of it.

C.

UTF-8 is one of the ways of representing UNICODE code points.

D.

ASCII is the name of a character coding standard

Question 7

Assuming that the snippet below has been executed successfully, which of the following expressions will evaluate to True? (Select two answers)

string = 'SKY' (:: -1)

string = string (-1)

Options:

A.

string is None

B.

string (0) == string (-1

C.

string (0) == 'Y'

D.

len (string) == 1

Question 8

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 9

Which one of the platform module functions should be used to determine the underlying platform name?

Options:

A.

platform.uname ()

B.

platform.platform ()

C.

platform.python_version()

D.

platform.processor()

Question 10

What is true about Python class constructors? (Choose two.)

Options:

A.

there can be more than one constructor in a Python class

B.

the constructor must return a value other than None

C.

the constructor is a method named __init__

D.

the constructor must have at least one parameter

Question 11

Assuming that the code below has been executed successfully, which of the following expressions will always evaluate to True? (Select two answers)

import random

v1 = random. random()

v2 = random. random()

Options:

A.

len(random.sample([1,2,3],2)) > 2

B.

v1 == v2

C.

random.choice([1,2,3]) >=1

D.

v1 >= 1

Question 12

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 13

What is the expected behavior of the following code?

Options:

A.

It outputs False

B.

It outputs nothing

C.

It outputs True

D.

It raises an exception

Question 14

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

Options:

A.

121 +1 == int ('1' + 2 * '2')

B.

float ('3.14') == str('3.'+'14')

C.

'xyz'.lower() 'XY'

D.

'8' + '8' !=2 * '8'

Question 15

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

Options:

A.

BB

B.

CC

C.

AA

D.

BC

Question 16

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

Options:

A.

str(1-1) in '012345£739'[:2]

B.

'phd' in 'alpha'

C.

'deb' not in 'abcde' [::-1]

D.

'True' not in 'False'

Question 17

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

Options:

A.

obj_b.prop_a == 3

B.

hasattr(obj_b, 'prop_aa')

C.

isinstance(obj_c,A)

D.

B. VarA == 3

Question 18

The following expression

1+-2

is:

Options:

A.

equal to 1

B.

invalid

C.

equal to 2

D.

equal to -1

Question 19

What is the expected behavior of the following code?

It will:

Options:

A.

print 0

B.

cause a runtime exception

C.

prints 3

D.

print an empty line

Question 20

What is the expected output of the following snippet?

Options:

A.

abc

B.

The code will cause a runtime exception

C.

ABC

D.

123

Question 21

What is the expected output of the following code?

Options:

A.

abcef

B.

The program will cause a runtime exception error

C.

acdef

D.

abdef

Question 22

What is the expected behavior of the following code?

Options:

A.

the code is erroneus and it will not execute

B.

it outputs [2, 4]

C.

it outputs [4, 2]

D.

it outputs [0, 1, 2, 3, 4]

Question 23

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?

Options:

A.

0

B.

-1

C.

an errno value corresponding to file not found

D.

2

Question 24

What is the expected behavior of the following code?

Options:

A.

it outputs [1, 3]

B.

the code is erroneous and it will not execute

C.

it outputs [3, 1]

D.

it outputs [4, 2, 0]

Question 25

What is the expected behavior of the following code?

Options:

A.

it outputs 'None'

B.

it outputs 3

C.

it raises an exception

D.

it outputs 0

Question 26

What is the expected output of the following code?

def foo(x,y,z):

return x(y) - x(z)

print{f00(lambda x: x % 2, 2, 1) )

Options:

A.

1

B.

0

C.

-1

D.

an exception is raised

Question 27

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 28

Which of the following literals reflect the value given as 34.23? (select two answers)

Options:

A.

.3423e2

B.

3423e-2

C.

.3423e-2

D.

3423e2

Question 29

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

Options:

A.

except Ex1 Ex2:

B.

except (ex1, Ex2):

C.

except Ex1, Ex2:

D.

except Ex1+Ex2:

Question 30

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

Options:

A.

.

B.

&

C.

_

D.

+

Question 31

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

Options:

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 32

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

Options:

A.

sequential

B.

named

C.

positional

D.

keyword

Question 33

Assuming that the following code has been executed successfully, selected the expression which evaluate to True (Select two answers)

Options:

A.

a ( ) == 4

B.

a is not None

C.

b ( ) == 4

D.

a ! = b

Question 34

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

Options:

A.

len(a) == len (b)

B.

b[0] fe- 1 == a[0]

C.

a [0] == b [0]

D.

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

Question 35

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 36

What is the expected output of the following snippet?

Options:

A.

the code is erroneous

B.

3

C.

7

D.

15

Question 37

What is the expected behavior of the following code?

Options:

A.

it outputs list assignment index out of range

B.

the code is erroneous and it will not execute

C.

it outputs

D.

it outputs error

Question 38

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

Expected output:

1 2 3

Code:

Options:

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 39

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

Options:

A.

1

B.

0

C.

2

D.

the variable becomes unavailable

Question 40

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)

Options:

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

Question 41

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 42

What is true about Python packages? (Select two answers)

Options:

A.

the__name__variable always contains the name of a package

B.

a package is a group of related modules

C.

the pyc extension is used to mark semi-compiled Python packages

D.

a package is a single file whose name ends with the pa extension

Question 43

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

Options:

A.

is instance(obj_b,C)

B.

C._C__VarA == 2

C.

has atr (B, 'get')

D.

obj_c.get() == 2

Question 44

Which of the following invocations are valid? (Select two answers)

Options:

A.

sorted ("python'')

B.

"python" .sort ( )

C.

sort" ("python")

D.

"python' ,find (" ")

Question 45

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

Options:

A.

BB

B.

CC

C.

AA

D.

BC

Question 46

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

Options:

A.

ch = read(s, 1)

B.

ch = s. input(1)

C.

ch = input(s, 1)

D.

ch = s. read(l)

Page: 1 / 12
Total 154 questions