Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

To insure that file output is written to the disk you need to execute what method? a. commit() b. write() c. close() d. complete() The

To insure that file output is written to the disk you need to execute what method?

a. commit()

b. write()

c. close()

d. complete()

The following is called the ________ of a function.

def myFunction(x,y) :

a. header

b. footer

c. sentinel

d. index

True or False: A commonly used program that uses regular expressions is grep.

True or False: In Python exception handling provides a mechanism for passing control from the point of the error detection to a handler than can deal with error.

True or False: A stub function is a function that acts as a placeholder and returns a simple value so another function can be tested.

What two items do you need to specify when reading a file in Python?

a. a file name and file properties

b. a file name and mode

c. a file name and size

d. a file name and data type

What happens if you try to open a file for input(read mode), but that file does not exist?

a. A default file, data.txt, is created as a new empty file

b. The program raises an exception

c. All attempts to read from the file return an empty string

d. All attempts to read from the file return random values

Assume string s = "red yellow blue". You then use y = s.split() to convert string s into a list. Which statement would print "blue"?

a. print(s[0])

b. print(y[1])

c. print(y[2])

d. print(s[2])

e. none of the above

The name of this function is ____________.

def m(x, y) :

z = x + y

return z

a. m

b. x

c. y

d. z

For this code, what is the point of this line: global total.

total = 0

def main() :

global total

avg = 0

for i in range(6):

total += i * i

avg = total / i

print (""Total, Avg"", total, avg)

a. "It does nothing, and could be removed without consequence"

b. it tells us that the local variable total is off limits

c. it is there to remind us that total is a local variable

d. it allows modifying the global variable total inside function

Which of the following is NOT a good practice when developing a computer program?

a. Put as many statements as possible into the main function and make it a giant jumble of code.

b. Document the purpose of each parameter.

c. Decompose a program into many small methods.

d. Place code that is used multiple times into a separate function.

A file has been opened for writing. Which of the following writes these 2 words, each word on a separate line. "Hello World"

a. outfile.print("Hello ", "World ")

b. outfile.write("Hello ", "World ")

c. outfile.print("Hello \World ")

d. outfile.write("Hello World ")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions