Skip to main contentSkip to solution

Arrange the following Python Code in order:

(A) try:

numerator=50

denom=int(input("Enter the denominator: "))

quotient=(numerator/denom)

print ("Division performed successfully")

(B) finally:

print ("OVER AND OUT")

(C) else:

print ("The result of division operation is ", quotient)

(D) except ZeroDivisionError:

print ("Denominator as ZERO is not allowed")

Solution

✅ Correct Option: 4

The order of a Python exception-handling block is try, except, else, finally.

(A) try: holds the code that may raise an error

(D) except ZeroDivisionError: runs only if the error occurs

(C) else: runs only if the try block raised no exception

(B) finally: always runs last, whether or not an exception occurred


Option 1: else cannot come before except. Python gives a syntax error.

Option 2: finally must be the last clause, so it cannot come before else.

Memory trick: try, except, else, finally (TEEF).

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question