Consider the following code:
___:
num=50
demon= int(input("Enter the denominator"))
quotient=(num/denom)
print("Division done")
____ZeroDivisionError:
print("Denominator is zero...not allowed")
___:
print("The result of division sis", quotient)
___:
print("Completed")
Arrange the following keywords to be filled in the blank spaces of the above code.
(A) else
(B) except
(C) finally
(D) try
Consider the following code:
___:
num=50
demon= int(input("Enter the denominator"))
quotient=(num/denom)
print("Division done")
____ZeroDivisionError:
print("Denominator is zero...not allowed")
___:
print("The result of division sis", quotient)
___:
print("Completed")
Arrange the following keywords to be filled in the blank spaces of the above code.
(A) else
(B) except
(C) finally
(D) try
Solution
✅ Correct Option: 1
The blanks must follow the structure of Python exception handling, in this order:
- try: holds the code that may raise an error (the input and division).
- except ZeroDivisionError: runs only if that error occurs.
- else: runs only if the try block finished with no exception, so it prints the result.
- finally: runs always, whether or not an exception occurred, so it prints "Completed".
Option 3: else cannot come before except. It must follow all except blocks.
Options 2 and 4: finally must be the last clause, and the block must begin with try.
Related questions:
2025: 3 June Shift 2
2026: 18 May Shift 2
2026: 31 May Shift 1
2026: 20 May Shift 1
2026: 23 May Shift 1