Courseiva
StringsmediumDrag & DropObjective-mapped

PCAP Strings Practice Question

Drag and drop the steps to handle an exception in Python using try-except-finally into the correct order.

Drag steps to the numbered slots on the right, or tap a step then tap a slot.

Steps
Order
1Step 1
2Step 2
3Step 3
4Step 4
5Step 5

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 block, then except block(s), then else block, then finally block

Exception handling follows the order: try block, except blocks, else block, finally block. The raise statement can be used anywhere to trigger an exception.

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 block, then except block(s), then else block, then finally block

    Why this is correct

    This is the correct order because the try block must be first to monitor code for exceptions. Except blocks immediately follow to handle specific exceptions. The else block runs if no exception occurs, and finally always executes after, regardless of exceptions.

  • try block, then except block(s), then finally block, then else block

    Why it's wrong here

    This is incorrect because the else block should come before the finally block. The else block executes only if no exception was raised, and it should be placed after except handlers but before the finally block, which always executes.

  • try block, then else block, then except block(s), then finally block

    Why it's wrong here

    This is incorrect because the except block(s) must come immediately after the try block, before the else block. The else block is only executed if no exception occurs, so it needs to be after all except handlers.

  • else block, then try block, then except block(s), then finally block

    Why it's wrong here

    This is incorrect because the try block must be placed first, as it defines the code to be monitored for exceptions. The else block cannot come before try because it depends on the absence of exceptions from the try block.

About these practice questions

Courseiva writes every PCAP question from scratch — 169 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 PCAP 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 PCAP exam.