Arrange the following in correct order of exception handling in python:
(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:
Example Code Structure:
try: # (A) Try block first
# risky code
except ValueError: # (C) Then exception handling
# handle error
finally: # (B) Cleanup comes next
# cleanup code
raise Error() # (D) Raising comes last when needed
List-I | List-II |
(A) f.seek(-10,1) | (I) From beginning of file, move 10 bytes forward |
(B) f.seek(10,1) | (II) From current position, move 10 bytes backward |
(C) f.seek(10) | (III) From current position, move 10 bytes forward |
(D) f.seek(-10,2) | (IV) From end of the file, move 10 bytes backward |
List-I (Words) | List-II (Definitions) |
(A) Theocracy | (I) One who keeps drugs for sale and puts up prescriptions |
(B) Megalomania | (II) One who collects and studies objects or artistic works from the distant past |
(C) Apothecary | (III) A government by divine guidance or religious leaders |
(D) Antiquarian | (IV) A morbid delusion of one’s power, importance or godliness |