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
Give section of code that prompts the user for an integer value, and displays the number entered if no exception is raised, otherwise catches the exception when a non-numeric character is entered, displaying the message "non-digit found in input."
Free
(Essay)
4.9/5
(39)
Correct Answer:
The expression int('10A') would raise a ________________ exception on Python.
Free
(Short Answer)
4.7/5
(40)
Correct Answer:
ValueError
The predefined exceptions in Python are called the ____________ exceptions.
Free
(Short Answer)
4.8/5
(30)
Correct Answer:
standard
A file may be closed and then reopened, with reading starting at the beginning of the file.
(True/False)
5.0/5
(30)
Exceptions must be caught and handled by the calling code of the function throwing the exceptions.
(True/False)
4.9/5
(39)
Provide Python code that prompts the user for the file name of the form filename.txt of a text file, opens the file, and displays each of the names on the screen, one per screen line.
(Short Answer)
4.8/5
(38)
Write a function called getNum(start, end) that is passed the starting and ending values of a range of integers, prompts the user to enter an integer in the specified range, and returns the integer entered. The function should throw a ValueError exception if the entered number is not within the required range.
(Essay)
5.0/5
(26)
If an exception is thrown all the back to the main module and not handled there, the program terminates.
(True/False)
4.9/5
(41)
When the end-of-file is reached when reading from a text file, an error is generated.
(True/False)
4.7/5
(36)
The expression 'Hello' + 10 would raise a _________________ exception on Python.
(Short Answer)
4.8/5
(40)
Give Python code that displays the longer of two names, name1 and name2.
(Essay)
4.8/5
(32)
Binary files are structured as separate lines as with text file, but can contain numerical data and therefore cannot be directly displayed on the screen.
(True/False)
4.9/5
(34)
in Python, files are accessed through method calls to an object associated with the open file.
(True/False)
4.8/5
(34)
An exception is an object that is raised when an unexpected situation has occurred.
(True/False)
4.8/5
(40)
Any of the sequence methods of Python may be applied to strings.
(True/False)
4.8/5
(39)
The newline character causes a new line of text to begin when displayed on the screen.
(True/False)
4.7/5
(26)
An exception is a value (object) that is __________ when an exceptional situation occurs.
(Short Answer)
4.8/5
(39)
Write a function called getYearOfBirth that prompts the user to enter their year of birth as a four-digit number, and returns the year entered. The function should throw a ValueError exception if the entered number is not within the range 1900 to the present year. Write a program that call this function, and keeps calling it until a valid year has been entered.
(Essay)
4.9/5
(33)
The ________ and __________ string methods in Python can be used to determine if a string contains only lowercase or uppercase characters, whereas the __________ and ___________ methods can be used to convert a string to all lowercase or all uppercase characters.
(Short Answer)
4.8/5
(36)
When a program opens a file in Python, the file must reside in the same directory (folder) as the program in order to be found.
(True/False)
4.9/5
(35)
Showing 1 - 20 of 58
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)