Computer Science
Assertion (A): Exception handling code is separate from normal code.
Reasoning (R): Program logic is different while exception handling code uses specific keywords to handle exceptions.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Python Exception Handling
1 Like
Answer
Both A and R are true and R is the correct explanation of A.
Explanation
Exception handling code is separate from normal code in programming languages. Exception handling code uses specific constructs like try, except, finally (in Python). Exception handling involves a different flow of control compared to regular program logic. When an exception occurs, the program jumps to the corresponding exception handling block (such as the except block in Python) rather than following the normal sequence of statements.
Answered By
3 Likes
Related Questions
Forced exceptions are indicated using which of the following keywords?
- try
- except
- finally
- raise
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.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
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.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Assertion (A): No matter what exception occurs, you can always make sure that some common action takes place for all types of exceptions.
Reasoning (R): The finally block contains the code that must execute.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.