Computer Science

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.

Python Exception Handling

1 Like

Answer

Both A and R are true and R is the correct explanation of A.

Explanation
In Python, the structure of exception handling using clear and distinct blocks like try, except, and finally helps in organizing code. It separates the code where exceptions might occur (within the try block) from the code responsible for handling those exceptions (within the except and finally blocks).

Answered By

1 Like


Related Questions