Exam 9: Files and Exceptions
Exam 1: Introduction to Computers and Python 28 Questions
Exam 2: Introduction to Python Programming 32 Questions
Exam 3: Control Statements and Program Development 20 Questions
Exam 4: Functions 18 Questions
Exam 5: Sequences: Lists and Tuples 25 Questions
Exam 6: Dictionaries and Sets 27 Questions
Exam 7: Array-Oriented Programming With Num 18 Questions
Exam 8: Strings: a Deeper Look 20 Questions
Exam 9: Files and Exceptions 30 Questions
Exam 10: Object-Oriented Programming 42 Questions
Exam 11: Computer Science Thinking: Recursion, Searching, Sorting and Big O18 Questions
Exam 12: Natural Language Processing 22 Questions
Exam 13: Data Mining Twitter 15 Questions
Exam 14: Ibm Watson and Cognitive Computing 31 Questions
Exam 15: Machine Learning: Classification, Regression and Clustering 66 Questions
Exam 16: Deep Learning 76 Questions
Exam 17: Big Data: Hadoop, Spark, Nosql and Iot 79 Questions
Select questions type
Various types of exceptions can occur when you work with files. Which of the following statements a), b) or c) is false?
(Multiple Choice)
4.8/5
(32)
The int function raises a ________ if you attempt to convert to an integer a string (like 'hello') that does not represent a number.
(Multiple Choice)
4.9/5
(45)
The following code uses exception handling to xe "except clause"catch and xe "handle (or resolve) an exception"handle any ValueErrors and ZeroDivisionErrors that arise. 1 while True:
2 try:
3 number1 = int(input('Enter numerator: '))
4 number2 = int(input('Enter denominator: '))
5 result = number1 / number2
6 except ValueError:
7 print('You must enter two integers\n')
8 except ZeroDivisionError:
9 print('Attempted to divide by zero\n')
10 else:
11 print(f'{number1:.3f} / {number2:.3f} = {result:.3f}')
12 break
Where in the code could either or both of these errors arise?
(Multiple Choice)
4.9/5
(38)
Showing 21 - 30 of 30
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)