Pre-Summer Special Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: validbest

Pass the Python Institute PCAP PCAP-31-03 Questions and answers with ValidTests

Exam PCAP-31-03 All Questions
Exam PCAP-31-03 Premium Access

View all detail and faqs for the PCAP-31-03 exam

Viewing page 4 out of 5 pages
Viewing questions 31-40 out of questions
Questions # 31:

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

Options:

A.

s.write("Hello\n")

B.

write(s, "Hello")

C.

s.writeln("Hello")

D.

s.writeline("Hello")

Expert Solution
Questions # 32:

What is the expected output of the following snippet?

Question # 32

Options:

A.

1

B.

4

C.

2

D.

3

Expert Solution
Questions # 33:

What is the expected behavior of the following snippet?

Question # 33

It will:

Options:

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.

print3

Expert Solution
Questions # 34:

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

Expert Solution
Questions # 35:

What is the expected output of the following snippet?

Question # 35

Options:

A.

3

B.

1

C.

2

D.

the code is erroneous

Expert Solution
Questions # 36:

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

string = 'python' [::2]

string = string[-1] + string[-2]

Options:

A.

string[0] == string[-1]

B.

string is None

C.

len (string] == 3

D.

string[0] == 'o'

Expert Solution
Questions # 37:

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

Expert Solution
Questions # 38:

What is the expected output of the following code if the file named existing_text_file is a non-zero length text file located inside the working directory?

Question # 38

Options:

A.

the length of the first line from the file

B.

-1

C.

the number of lines contained inside the file

D.

the length of the last line from the file

Expert Solution
Questions # 39:

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

Question # 39

Options:

A.

a is not None

B.

a ! =b

C.

b () ==4

D.

a () == 4

Expert Solution
Questions # 40:

What is the expected behavior of the following code?

Question # 40

It will:

Options:

A.

print 0

B.

cause a runtime exception

C.

prints 3

D.

print an empty line

Expert Solution
Viewing page 4 out of 5 pages
Viewing questions 31-40 out of questions