Courseiva

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

A developer writes: num = input('Enter a number: '); result = num * 2; print(result). If the user enters 5, what is the output?

⚠ Common exam trap

Python Institute often tests the misconception that `input()` returns a numeric type when the user types digits, leading candidates to expect arithmetic multiplication 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

✓

55

The `input()` function always returns a string. When the user enters '5', `num` is the string '5', not the integer 5. The `*` operator on a string performs repetition, so `'5' * 2` produces '55', which is printed as 55.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Error: cannot multiply string by int

    Why it's wrong here

    Multiplying a string by an integer is legal in Python, so no error occurs; `input()` returns the string `'5'`, and `'5' * 2` repeats it, printing `55`. The error claim tempts because multiplying two strings, or a string by a float, does raise `TypeError` — but repetition by an integer is valid.

  • ✗

    10

    Why it's wrong here

    Entering 5 yields '55', not 10, because input() returns a string and string repetition by 2 concatenates it with itself. The value 10 would appear only after converting with int(num) or float(num). This option is tempting because multiplying a numeric 5 by 2 does give 10, so it reflects the intended arithmetic rather than Python's actual string behaviour.

  • ✗

    '5' * 2

    Why it's wrong here

    The `input()` function returns a string, so `num * 2` repeats the string rather than doubling the integer, printing `55`. This option is tempting because string repetition is genuine Python behaviour, and it would be the correct output had the code converted the input using `int()` first.

  • ✓

    55

    Why this is correct

    `input()` returns a string, so `num` holds `'5'`, not the integer 5. Multiplying a string by 2 repeats it, giving `'55'`, which `print()` outputs without quotes. The stem's constraint is that no `int()` conversion is applied before the multiplication.

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 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.