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

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

Exhibit

Traceback (most recent call last):
  File "script.py", line 3, in <module>
    result = "5" + 10
TypeError: can only concatenate str (not "int") to str

Refer to the exhibit. What is the cause of the error?

⚠ Common exam trap

Python Institute often tests the misconception that Python will automatically convert types (like JavaScript does), leading candidates to think the code will run without error, when in fact Python raises a TypeError for mixed-type `+` operations.

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 + on incompatible types (str and int)

The error occurs because the `+` operator is being used between a string and an integer, which are incompatible types in Python. Python does not implicitly convert the integer to a string for concatenation; it raises a `TypeError: unsupported operand type(s) for +: 'str' and 'int'`.

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 + on incompatible types (str and int)

    Why this is correct

    Python cannot concatenate string and int without conversion.

  • Division by zero

    Why it's wrong here

    No division in the code.

  • Missing import statement

    Why it's wrong here

    No import needed for basic operations.

  • Variable not defined

    Why it's wrong here

    The variable 'result' is being assigned.

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.