Ch. 6
Which mode specifier will open a file but will not let you change the file or write to it? 'w' 'r' 'a' 'e'
'r'
Which mode specifier will erase the contents of a file if it already exists and create it if it does not exist? 'w' 'r' 'a' 'e'
'w'
How many types of files are there? One Two Three Four
Two
Assume that the customer file references a file object, and the file was opened using the 'w' mode specifier. How would you write the string 'Mary Smith' to the file? customer_file.write('Mary Smith') customer.write('w','Mary Smith') customer.input('Mary Smith') customer.write('Mary Smith')
customer.write('Mary Smith')
When a file has been opened using the 'r' mode specifier, which method will return the file's contents as a string? write input get read
read
Which method will return an empty string when it has attempted to read beyond the end of a file? read getline input readline
readline
Which method could be used to strip specific characters from the end of a string? estrip rstrip strip remove
rstrip
Which method could be used to convert a numeric value to a string? str value num ch
str
Which step creates a connection between a file and a program? Open the file. Read the file. Process the file. Close the file.
Open the file
What do you call the process of retrieving data from a file? Retrieving data Reading data Input data Get data
Reading data