Write the following Python Program in correct sequence ?
(A) print("Handling exception using try...except...else")
(B) except ZeroDivisonError:
print("Denominator as zero is not allowed")
(C) else :
print("the result of division operation is quotient")
(D)try :
numerator =50
denom=int(input("enter the denominator:"))
quotient=(numerator/denom)
print("Division performed successfully")
Write the following Python Program in correct sequence ?
(A) print("Handling exception using try...except...else")
(B) except ZeroDivisonError:
print("Denominator as zero is not allowed")
(C) else :
print("the result of division operation is quotient")
(D)try :
numerator =50
denom=int(input("enter the denominator:"))
quotient=(numerator/denom)
print("Division performed successfully")
Solution
A try block must come first, followed by except, and else comes last. The introductory print statement (A) comes before the whole structure.
(A) print("Handling exception using try...except...else")
(D) try: block with the numerator, input, division and the success message
(B) except ZeroDivisionError: block that handles division by zero
(C) else: block that runs only if the try block raised no exception
Option 4: else cannot come before except. In try...except...else, the else clause must follow all except clauses.
Options 1 and 3: except cannot appear without a try before it, so (B) cannot come before (D).
Related questions:
2025: 21 May Shift 1
2026: 23 May Shift 2