Test Series - python

Test Number 114/108

Q: Which of the following is not a standard exception in Python?
A. NameError
B. IOError
C. AssignmentError
D. ValueError
Solution: NameError, IOError and ValueError are standard exceptions in Python whereas Assignment error is not a standard exception in Python.
Q: Syntax errors are also known as parsing errors.
A. True
B. False
C. none
D. ..
Solution: Syntax errors are known as parsing errors. Syntax errors are raised when there is a deviation from the rules of a language. Hence the statement is true.
Q: An exception is ____________
A. an object
B. a special function
C. a standard module
D. a module
Solution: An exception is an object that is raised by a function signaling that an unexpected situation has occurred, that the function itself cannot handle.
Q: _______________________ exceptions are raised as a result of an error in opening a particular file.
A. ValueError
B. TypeError
C. ImportError
D. IOError
Solution: IOError exceptions are raised as a result of an error in opening or closing a particular file.
Q: Which of the following blocks will be executed whether an exception is thrown or not?
A. except
B. else
C. finally
D. assert
Solution: The statements in the finally block will always be executed, whether an exception is thrown or not. This clause is used to close the resources used in a code.

You Have Score    /5