Services
Discover
Ask a Question
Log in
Sign up
Filters
Done
Question type:
Essay
Multiple Choice
Short Answer
True False
Matching
Topic
Computing
Study Set
Computer Science Using Python
Exam 8: Text Files
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Question 41
True/False
An exception handler is the section of code that is executed when a particular exception type is caught.
Question 42
True/False
When writing a line of text to a text file, the write method does not add a newline character to the output string.
Question 43
Short Answer
To open a file for writing, the built-in _________ method is used, called with a required second parameter of ____.
Question 44
True/False
Python contains a predefined set of exceptions called standard exceptions.
Question 45
True/False
To open a file in Python for reading, the openRead function is called and passed the name of the file to open.
Question 46
Short Answer
Provide Python code that opens a file named names.txt, in which each line of the file contains a friends name in the form firstname lastname, and displays each of the names on the screen, one per screen line.
Question 47
Short Answer
A ___________________ is a file containing characters structured as lines of text, as well as nonprinting characters such as \n, the newline character.
Question 48
True/False
It is more likely that an error may occur when opening a file for writing than when opening a file for reading.
Question 49
Short Answer
Collectively, the operations performed on strings is called _______________________.
Question 50
True/False
All raised exceptions should be able to be caught and handled to keep a program executing.
Question 51
True/False
Strings are immutable in Python, and therefore cannot be altered.
Question 52
Essay
Give Python code that display "Valid SSN" if the string assigned to variable SSN is a valid social security number, and displays "Invalid SSN" otherwise. A social security number is valid if it contains exactly nine digits, and no other characters.
Question 53
Short Answer
When opening a file for reading, an error that may occur is ______________________________.
Question 54
True/False
The section of code making a call to any function that raises an exception must be contained in a try suite (block).
Question 55
Short Answer
Fundamental operations of files in include opening a file, _______ a file, __________ a file, and___________ a file.
Question 56
Essay
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), assigns the first name to variable first_name and the last name to variable last_name.