CBSE Class 12 Computer Science Question 16 of 30

Exception Handling — Question 2

Back to all questions
2
Question

Question 2

List the situation(s) in which the following errors occur:

(a) IOError

(b) NameError

(c) ValueError

(d) TypeError

Answer

(a) IOError — This error is raised if the requested file cannot be opened, or failure of I/O operation.

(b) NameError — This error is raised when an identifier is not found in the local or global namespace.

(c) ValueError — This error is raised when a built-in operation or function receives an argument that has the right type but an inappropriate value.

(d) TypeError — This error is raised when an operation or function is attempted that is invalid for the specified data type.