Courseiva
Functions, Tuples, Dictionaries and ExceptionshardMultiple SelectObjective-mapped

PCEP Practice Question: Functions, Tuples, Dictionaries and Exceptions

Which THREE of the following are valid ways to handle an exception in Python?

⚠ Common exam trap

Python Institute often tests the rule that an `else` block cannot exist without at least one `except` block, and that a `finally` block must always be attached to a `try` block, leading candidates to mistakenly think these standalone constructs are 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

Using a `try` block with both `except` and `finally` blocks.

Python's exception handling allows a `try` block to be followed by both `except` and `finally` blocks. The `except` block catches specific exceptions, while the `finally` block always executes (for cleanup), regardless of whether an exception occurred. This combination is fully valid and commonly used for robust resource management.

Answer analysis

Option-by-option breakdown

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

  • Using a `try` block with both `except` and `finally` blocks.

    Why this is correct

    Combination is valid.

  • Using a `finally` block without a `try` block.

    Why it's wrong here

    `finally` must be associated with a `try`.

  • Using a `try` block with an `else` block but no `except` block.

    Why it's wrong here

    `else` requires an `except` block.

  • Using a `try` block with a `finally` block.

    Why this is correct

    `finally` always executes.

  • Using a `try` block with one or more `except` blocks.

    Why this is correct

    Standard structure.

About these practice questions

Courseiva writes every PCEP question from scratch — 498 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 PCEP practice question is part of Courseiva's free Python Institute 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 PCEP exam.