Exam 8: Text Files
Exam 1: Introduction102 Questions
Exam 2: Data and Expressions71 Questions
Exam 3: Control Structures129 Questions
Exam 4: Lists85 Questions
Exam 5: Functions83 Questions
Exam 6: Objects and Their Use54 Questions
Exam 7: Modular Design62 Questions
Exam 8: Text Files58 Questions
Exam 9: Dictionaries and Sets33 Questions
Exam 10: Object-Oriented Programming81 Questions
Exam 11: Recursion27 Questions
Select questions type
When writing to or reading from to a file, data is placed in an area of memory called a __________, which make the reading and writing of files more efficient.
(Short Answer)
4.8/5
(33)
Give Python code that, for any state of the U.S. assigned to variable state_name, displays the name ensuring that the first letter is displayed capitalized.
(Essay)
4.9/5
(31)
To open a file for writing in Python, 'w' is used to indicate that any existing file of the same name should be written over, and 'a' is used to indicate that the output should be appended to an existing file.
(True/False)
4.8/5
(35)
When reading a line from a text file, the ________________ method is used.
(Short Answer)
4.8/5
(43)
Give Python code that, for a first name and last name assigned to variable full_name with the first and last name separated by a single space (e.g., Alice Morgan), displays the first name only.
(Essay)
4.8/5
(39)
Although files should be closed after being opened for either reading or writing. it is especially important to close a file that is open for writing.
(True/False)
4.8/5
(43)
A ___________________ is a file containing various types of data, such as numerical data, and is not structured as lines of text.
(Short Answer)
4.9/5
(32)
Exceptions that are thrown by a given function must be caught by the function to gracefully handle errors.
(True/False)
4.9/5
(42)
55. The section of code that is to be executed when a particular exception has been caught is called an _____________________________.
(Short Answer)
4.8/5
(38)
24. When reading a line from a text file, all the characters up to and including the ___________ character are read and returned.
(Short Answer)
4.9/5
(26)
The ________ string method in Python can be used to determine if a string contains only letters, whereas the __________ method can be used determine is a string contains only digits.
(Short Answer)
4.7/5
(29)
Which of the following is not a standard exception in Python?
(Multiple Choice)
4.9/5
(33)
Provide Python code that prompts the user for the file name of the form filename.txt of a text file, opens the file, and writes the contents of the file to a new file name filename-2.txt.
(Short Answer)
4.8/5
(42)
Any string method involving the modification of a string returns a new string containing the modification, with the original string the method is called on unchanged.
(True/False)
4.8/5
(44)
When reading from a text file, the readline method is used, which returns all the characters on the current line of the file, up to but not including the newline character.
(True/False)
4.9/5
(29)
All files must first be opened before they can be read from or written to.
(True/False)
4.9/5
(39)
Give Python code that removes any occurrences of dashes from a given social security number that variable SSN is assigned to, and updates SSN to contain the dash-removed result.
(Essay)
4.8/5
(38)
To open a file for reading, the built-in _________ method is used, called with an optional second parameter of ____.
(Short Answer)
4.9/5
(38)
Showing 21 - 40 of 58
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)