Bird
0
0

What will be the output of the following code?

medium📝 Predict Output Q13 of 15
Python - Advanced Exception Handling
What will be the output of the following code?
try:
    print("Start")
    x = 1 / 1
except ZeroDivisionError:
    print("Error")
else:
    print("No Error")
print("End")
AStart\nNo Error\nEnd
BStart\nEnd
CError\nNo Error\nEnd
DStart\nError\nEnd
Step-by-Step Solution
Solution:
  1. Step 1: Analyze try block execution

    The code prints "Start" and calculates 1/1 which is 1, no error occurs.
  2. Step 2: Determine which blocks run

    Since no error, except block is skipped, else block runs printing "No Error", then "End" prints after.
  3. Final Answer:

    Start No Error End -> Option A
  4. Quick Check:

    No error means else runs = D [OK]
Quick Trick: If no error, else runs after try [OK]
Common Mistakes:
  • Thinking except runs without error
  • Ignoring else block output
  • Missing that print("End") always runs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes