Courseiva

PCEP Computer Programming and Python Fundamentals Practice Question

A developer writes a short script to convert a numeric string entered at the console into a number for arithmetic:

value = input('Enter a quantity: ') total = value * 2

print(total)

A user types 7 and presses Enter. What is printed, and why?

⚠ Common exam trap

The trap here is assuming input returns a number when the user types digits, when it actually returns a string that triggers repetition with the * operator.

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

✓

77, because the string '7' is repeated twice by the * operator

The built-in input always yields a str in Python 3, so value refers to the two-character sequence '7'. When * receives a str on the left and an int on the right, it repeats the string that many times instead of multiplying numerically. The assignment therefore stores '77', and print outputs those characters. Converting with int(value) first would give the arithmetic result 14.

Answer analysis

Option-by-option breakdown

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

  • ✗

    14, because input converts the entry to an integer automatically

    Why it's wrong here

    input in Python 3 never performs numeric conversion; it always returns a str. The value '7' would need an explicit int or float call before multiplication could produce 14. The script as written multiplies text, not a number, so no arithmetic occurs and this output cannot appear.

  • ✗

    7, because the second operand is ignored for string values

    Why it's wrong here

    No operand is silently ignored; the * operator uses both operands to decide how many copies to produce. With a count of 2, the string is duplicated once to form a two-character result. If the count were 0 or negative, repetition would yield an empty string rather than the original text.

  • ✓

    77, because the string '7' is repeated twice by the * operator

    Why this is correct

    input returns the str '7'. The * operator applied to a str and an int performs repetition rather than multiplication, producing a new string containing the original text twice. The result is the two-character string '77', which print displays. Explicit conversion with int() would be required for numeric doubling.

  • ✗

    A TypeError is raised, because a string cannot be multiplied

    Why it's wrong here

    Multiplication of a str by an int is legal and yields repetition; only unsupported operand combinations, such as str times str, raise TypeError. Since the right operand is the int literal 2, the operation succeeds. The failure mode described would apply if the code attempted '7' * '2' instead.

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.