EXCEPTION HANDLING - Aseessment - 2
EXCEPTION HANDLING - Aseessment - 2
13
1. Look at the following code and select the correct description of error shown while
executing it:
X = int(input("Enter a Number"))
R=X*X
print "Square =", R
a. can only concatenate str (not "int") to str b. missing parenthesis in call to 'print'
c. name 'Print' is not defined d. none of the above
2. (i) Generally, all exceptions are generated when a program is syntactically correct.
(ii) SyntaxError is not considered as an exception.
a. (i) True, (ii) False b. (i) False, (ii) True c. Both are True d. Both are False
3. When an error occurs during the execution of a program, an exception is said to have been ____.
a. Created b. Asserted c. Triggered d. Raised
4. Which of the following is not a built-in exception in Python?
a. SyntaxError b. ValueError c. ZeroDivisionError d. ExportError
5. Which of the following describes the exception handling process correctly?
a. Exception raised -> searches for exception handler -> create exception object -> execute code of
exception handler
b. Exception raised -> create exception object -> searches for exception handler -> execute code of
exception handler
c. Create exception object -> exception raised -> searcher for exception handler -> execute code of
exception handler
d. Create exception object -> searches for exception handler -> exception raised -> execute code of
exception handler
6. Which of the following is not true?
(i) The statement inside the else block is executed regardless of whether the except block is executed
or not.
(ii) If an exception is encountered, further execution of the code inside the try block is stopped and
control is transferred to the except block.
a. (i) True, (ii) False b. (i) False, (ii) True
c. Both (i) and (ii) are True d. Both (i) and (ii) are False
Question 7. Assertion (A): Exception handling handles all types of errors and exceptions.
Reasoning (R): Exception handling is responsible for handling anomalous situations during the
execution of a program.
1. Both A and R are true and R is the correct explanation of A.
2. Both A and R are true but R is not the correct explanation of A.
3. A is true but R is false. 4. A is false but R is true.
Question 8 . Assertion (A): Exception handling code is clear and block based in Python.
Reasoning (R): The code where unexpected runtime exception may occur is separate from the code
where the action takes place when an exception occurs.
1. Both A and R are true and R is the correct explanation of A.
2. Both A and R are true but R is not the correct explanation of A.
3. A is true but R is false. 4. A is false but R is true.
9. Differentiate between IOError and IndexError 2 marks
10. What is the difference between an error and exception? 3 marks