Courseiva
Software Development and DesignmediumMultiple SelectObjective-mapped

200-901 Software Development and Design Practice Question

Which TWO of the following Python exception handling statements are valid? (Choose two.)

⚠ Common exam trap

Cisco often tests Python 2 vs Python 3 syntax changes, specifically the comma-based exception binding. Candidates may also mistakenly think that catching multiple exceptions with a tuple or using a bare except is valid.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

try:\n x = 1/0\nexcept ZeroDivisionError as e:\n print(e)

Options A and C are valid Python exception handling statements. Option A uses the correct `as` keyword to bind the exception instance. Option C shows proper syntax with multiple except blocks, where a generic `except:` can follow a specific except. Option B is invalid because it uses the obsolete comma syntax (`except ZeroDivisionError, e`), removed in Python 3. Option D is invalid because you cannot catch multiple exception types with a single `as` variable using a tuple; the syntax is not supported. Option E is invalid because a bare `except:` clause is considered poor practice and is not a valid 'exception handling statement' in this context—it catches all exceptions without specificity.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • try:\n x = 1/0\nexcept ZeroDivisionError as e:\n print(e)

    Why this is correct

    Correct syntax: `except ExceptionType as variable`.

  • try:\n x = 1/0\nexcept ZeroDivisionError, e:\n print(e)

    Why it's wrong here

    Obsolete comma syntax removed in Python 3.

  • try:\n x = 1/0\nexcept ZeroDivisionError:\n print('error')\nexcept:\n print('other error')

    Why this is correct

    Valid: multiple except blocks, with bare `except:` allowed.

  • try:\n x = 1/0\nexcept (ZeroDivisionError, TypeError) as e:\n print(e)

    Why it's wrong here

    Invalid: tuple of exceptions with `as` is not valid syntax.

  • try:\n x = 1/0\nexcept:\n print('error')

    Why it's wrong here

    Invalid: bare `except:` is not considered a valid exception handling statement.

About these practice questions

Courseiva writes every 200-901 question from scratch — 989 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This 200-901 practice question is part of Courseiva's free Cisco certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 200-901 exam.