Courseiva

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

A Python script contains the following assignment: `value = 5` followed by `result = value * '2'`. What is the value of `result` after these statements execute?

⚠ Common exam trap

The trap here is assuming that `*` always performs numeric multiplication, leading to an expectation of implicit conversion or a numeric result instead of string repetition.

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

✓

`'22222'`

The multiplication operator `*` behaves differently depending on operand types. When one operand is an integer and the other is a string, Python repeats the string that many times. With `value = 5` and string `'2'`, the result is `'22222'`. This is a common source of confusion for beginners who expect numeric multiplication or implicit type conversion. Recognizing the operand types is essential to predicting the outcome correctly.

Answer analysis

Option-by-option breakdown

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

  • ✗

    A `TypeError` is raised.

    Why it's wrong here

    A `TypeError` would occur if both operands were strings, because string repetition requires one operand to be an integer. Here, `value` is the integer `5` and `'2'` is a string, which is a valid combination for repetition. Therefore, no error is raised; the expression evaluates to the string `'22222'`.

  • ✓

    `'22222'`

    Why this is correct

    In Python, when the `*` operator has an integer and a string as operands, it performs repetition: the string is repeated that many times. With `value = 5` and the string `'2'`, the expression `value * '2'` produces the string `'22222'`, a five-character string. This is valid because string repetition is supported when one operand is an integer.

  • ✗

    `'10'`

    Why it's wrong here

    This option incorrectly assumes that multiplication of an integer and a string performs numeric multiplication. In Python, the `*` operator between an integer and a string repeats the string, not multiplies its numeric value. Here, `5 * '2'` repeats the one-character string `'2'` five times, yielding `'22222'`, not `'10'`.

  • ✗

    `10`

    Why it's wrong here

    This option assumes that Python automatically converts the string `'2'` to an integer and multiplies. Python does not perform implicit type conversion between strings and integers for multiplication. The `*` operator uses string repetition when one operand is a string and the other is an integer, so the result is a string, not the integer `10`.

About these practice questions

One of 482 original PCEP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Python Institute exam blueprint

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.