Another Programming Test

Ace your homework & exams now with Quizwiz!

To read each line of a file as an item in a list, use .listread() T&F

False

"w+" mode opens a file for write plus read, such as in the following code: schools= open("school_names.txt","w+")

True

.readline() is used to read one line, as a string, from an open text file (T&F)

True

a file opened in read mode cannot be changed (we cannot write to the file) T or F

True

Which is the best choice to complete the following sentence? Opening a file in Python using read mode ("r"):

makes file contents available for Python to read the file.

What choice will format the first line in te text file books.txt intitle format? books= open("books.txt","r")

print(books.readline().title())

What is the best choi`ce to complete the following sentece? Using .readline() tp read an open file results in :

reading each line in the file as an item in a list

To move the pointer in an open file to the first character, what should you use?

.seek(0)

To move the pointer 5 characters past the current pointer location, what should you use?

.seek(5,1)

Which answer best describes what .strip() does in the following code sample? poem_line= poem1.readline().strip()

.strip() removes the leading and trailing whitespace, including the 'n\'


Related study sets

Microsoft SC-200 Exam Actual Questions

View Set

Understanding Religion Estrads: Final

View Set

SOC 301 FINAL EXAM STUDY GUIDE TEST 3

View Set

Life insurance policy provisions, options, and riders

View Set