Summer Special Flat 65% Limited Time Discount offer - Ends in 0d 00h 00m 00s - Coupon code: suredis

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

Demo: 22 questions
Total 145 questions

Certified Associate in Python Programming Questions and Answers

Question 1

What is the expected behavior of the following code?

x - 3 % 1

y -1 if x > else 0

print (y)

Options:

A.

it outputs -1

B.

the code is erroneous and it will not execute

C.

it outputs 1

D.

it outputs 0

Question 2

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 3

What is the expected output of the following code?

Options:

A.

2

B.

3

C.

4

D.

an exception is raised

Question 4

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 5

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

Options:

A.

BB

B.

CC

C.

AA

D.

BC

Question 6

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

services. cpython-36.pyc

Options:

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

Question 7

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

Options:

A.

closing an open file is performed by the closefile ( ) function

B.

the second open ( ) argument describes the open mode and defaults to ‘w’

C.

if open ( ) ‘s second argument is ‘r’ the file must exist or open will fail

D.

if open ( )’s second argument is ‘w’ and the invocation succeeds, the previous file’s content is lost

Question 8

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 9

What is the expected output of the following code?

Options:

A.

3

B.

5

C.

4

D.

an exception is raised

Question 10

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

Options:

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 11

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 12

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

Options:

A.

len(a)== len (b)

B.

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

C.

a[0] = b[0]

D.

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

Question 13

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

Options:

A.

if a real-life object can be described with a set of adjectives, they may reflect a Python object method

B.

the same class can be used many times to build a number of objects

C.

each object of the same class can have a different set of methods

D.

a subclass is usually more specialized than its superclass

Question 14

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 15

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)

Question 16

Assuming that the math module has been successfully imported, which of the following expressions evaluate to True? (Select two answers)

Options:

A.

math. hypot (3,4) == math.sqrt (25)

B.

math. hypot (2,5) == math.truec (2.5)

C.

math. hypot (2,5) == math.true (2.5)

D.

math. cell (2,5) == math.floor (2.5)

Question 17

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 18

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

Options:

A.

' t '.upper () in 'Thames'

B.

'in not' in 'not'

C.

'not' not in 'in'

D.

'a' not in 'ABC' .lower ()

Question 19

What is the expected output of the following snippet?

Options:

A.

True lower

B.

True upper

C.

False upper

D.

False lower

Question 20

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 21

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 22

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:

Demo: 22 questions
Total 145 questions