Question:

Arrange the following in correct order of exception handling in python:
Options:
(A) Write the code that may raise an exception inside a try block
(B) Execute some code regardless of whether the exception occurs or not using the finally block
(C) Handle the specific exception using the except block
(D) Raise the exception using the raise statement if necessary
Choose the correct answer from the options given below:

Updated On: Nov 4, 2024
  • (A), (B), (C), (D)
  • (A), (C), (B), (D)
  • (B), (A), (D), (C)
  • (C), (B), (D), (A)
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

Correct order for handling exceptions: write code in ‘try‘, handle specific exceptions in ‘except‘, raise exceptions with ‘raise‘ if needed, and execute final actions with ‘finally‘.
Was this answer helpful?
0
0