Bird
0
0

What will be printed when this code runs?

medium📝 Predict Output Q4 of 15
Python - Exception Handling Fundamentals
What will be printed when this code runs?
try:
    result = 10 / 0
except Exception:
    print('Exception handled')
AException handled
BZeroDivisionError
CNo output
D10
Step-by-Step Solution
Solution:
  1. Step 1: Identify Exception

    Dividing by zero raises a ZeroDivisionError, which is a subclass of Exception.
  2. Step 2: Exception Handling

    The except Exception: block catches this error and executes the print statement.
  3. Final Answer:

    Exception handled is printed -> Option A
  4. Quick Check:

    ZeroDivisionError caught by generic handler [OK]
Quick Trick: ZeroDivisionError caught by except Exception [OK]
Common Mistakes:
  • Expecting program to crash
  • Thinking no output will occur
  • Confusing exception name with output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes