Python Exception Handling MCQ Test: 200 Interview Questions With Answers

← All Python MCQ topics and your readiness dashboard

Test your Exception Handling knowledge with a timed Python MCQ mock test for interviews. Each attempt gives you 20 random questions in 20 minutes from a 200-question bank covering try, except, else and finally, the exception hierarchy, catching several types, raise and re-raise, exception chaining with from, custom exception classes, context managers and suppress, ExceptionGroup and except*, add_note, tracebacks and logging, EAFP versus LBYL, and pytest.raises, retries, soft assertions, cleanup and clear failure messages in tests. 59 questions are written from a QA and test-automation angle and the rest from a developer angle; your result shows both scores.

What this Python MCQ test covers

Revise these lessons from the free Python tutorial before or after your test:

Sample Python Exception Handling questions with answers

  • Q. A test runner collecting failures. What does this code print?
    checks = {"title": lambda: None, "price": lambda: 1 / 0, "cart": lambda: [][1]}
    failures = []
    for name, check in checks.items():
    try:
    check()
    except Exception as e:
    failures.append(f"{name}: {type(e).__name__}")
    print(failures)

    Answer: ['price: ZeroDivisionError', 'cart: IndexError']
    Catching per check and collecting messages reports every failure at once.
  • Q. Retrying only transient errors. What does this code print?
    attempts = []
    def call():
    attempts.append(1)
    if len(attempts) < 3:
    raise ConnectionError("reset")
    return "200 OK"
    for _ in range(5):
    try:
    result = call()
    break
    except ConnectionError:
    continue
    print(result, len(attempts))

    Answer: 200 OK 3
    Retry on the specific transient error and stop at the first success.
  • Q. Not retrying real bugs. What does this code print?
    def call():
    raise TypeError("bad argument")
    try:
    for _ in range(3):
    try:
    call()
    except ConnectionError:
    continue
    except TypeError as e:
    print("failed fast:", e)

    Answer: failed fast: bad argument
    Because only ConnectionError is retried, a TypeError fails immediately.
  • Q. What does this code print?
    try:
    print(1 / 0)
    except ZeroDivisionError:
    print("div")

    Answer: div
    Dividing by zero raises ZeroDivisionError, which the except block handles.
  • Q. What does this code print?
    try:
    int("abc")
    except ValueError as e:
    print(type(e).__name__)

    Answer: ValueError
    int() of a non-numeric string raises ValueError.
  • Q. What does this code print?
    try:
    "1" + 1
    except TypeError:
    print("TypeError")
    except ValueError:
    print("ValueError")

    Answer: TypeError
    Adding str and int is a type mismatch, so TypeError.

Every predict-the-output question in this bank was run on Python 3, so the answer is the real output. Go back to the Python MCQ dashboard to see your overall Python learning progress and interview readiness.

Frequently asked questions

How many questions does the Python Exception Handling MCQ test have?

The bank has 200 questions. Each test picks 20 at random, favouring questions you have not seen yet, so about 10 attempts cover the whole bank.

How long is each test and what is the pass mark?

Each test has a 20-minute timer and submits itself when time runs out. You pass with 70%, which is 14 of 20 correct.

Is this test useful for QA and automation engineer interviews?

Yes. 59 of the questions use test-automation scenarios such as parsing UI text, test data and assertions, and your result shows your QA score separately.

Can I retake the test?

Yes, as often as you like. Every retake draws a fresh set of 20 questions and counts toward your 20-test readiness target.