Week 6 Flashcards
If a file with the specified name already exists when the file is opened and the file is opened in ‘w’ mode, then an alert will appear on the screen.
False
When a piece of data is read from a file, it is copied from the file into the program.
False
Closing a file disconnects the communication between the file and the program.
True
In Python, there is nothing that can be done if the program tries to access a file to read that does not exist.
False
Python allows the programmer to work with text and number files.
False
The ZeroDivisionError exception is raised when the program attempts to perform the calculation x/y if y = 0.
True
An exception handler is a piece of code that is written using the try/except statement.
True
If the last line in a file is not terminated with \n, the readline method will return the line without \n.
True
Strings can be written directly to a file with the write method, but numbers must be converted to strings before they can be written.
True
It is possible to create a while loop that determines when the end of a file has been reached.
True
Which of the following is associated with a specific file and provides a way for the program to work with that file?
a. the filename
b. the file extension
c. the file object
d. the file variable
c. the file object
What is the process of retrieving data from a file called?
a. retrieving data
b. reading data
c. reading input
d. getting data
b. reading data
Which of the following describes what happens when a piece of data is written to a file?
a. The data is copied from a variable in RAM to a file.
b. The data is copied from a variable in the program to a file.
c. The data is copied from the program to a file.
d. The data is copied from a file object to a file.
a. The data is copied from a variable in RAM to a file.
Which step creates a connection between a file and a program?
a. open the file
b. read the file
c. process the file
d. close the file
a. open the file
How many types of files are there?
a. one
b. two
c. three
d. more than three
b. two
A(n) __________ access file is also known as a direct access file.
a. sequential
b. random
c. numbered
d. text
b. random