Courseiva
Data Types, Variables, Basic I/O and OperatorsmediumMultiple ChoiceObjective-mapped

PCEP Practice Question: Data Types, Variables, Basic I/O and Operators

Exhibit

Refer to the exhibit.

def divide(a, b):
    try:
        result = a / b
        print('Result:', result)
    except ZeroDivisionError:
        print('Cannot divide by zero')
    except TypeError:
        print('Unsupported operand')

divide(10, 0)

What is the output when the following code is executed?

try:
    print(1/0)

except ZeroDivisionError:

print("Cannot divide by zero")

⚠ Common exam trap

Python Institute often tests the distinction between an unhandled exception (crash) and a caught exception (graceful handling). In this case, the exception is caught, so the program does not crash.

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

Cannot divide by zero

The code inside the try block attempts to divide by zero, which raises a ZeroDivisionError. The except block catches this exception and executes its print statement, outputting 'Cannot divide by zero'.

Answer analysis

Option-by-option breakdown

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

  • Cannot divide by zero

    Why this is correct

    ZeroDivisionError is caught.

  • The program crashes with an unhandled exception

    Why it's wrong here

    Exception is handled.

  • Result: 0

    Why it's wrong here

    The division does not execute.

  • Unsupported operand

    Why it's wrong here

    TypeError is not raised.

About these practice questions

This PCEP question is part of Courseiva's 498-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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.