Courseiva
Strings →easyMultiple Choice

PCAP Strings Practice Question

What is the result of the expression 'Hello' * 3?

⚠ Common exam trap

The Python Institute often tests the distinction between string repetition (*) and string concatenation (+), and the trap here is that candidates may incorrectly assume spaces are added or that an error occurs when multiplying a string by an integer.

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

✓

'HelloHelloHello'

In Python, the multiplication operator (*) on a string repeats the string a specified number of times. 'Hello' * 3 concatenates 'Hello' three times, producing 'HelloHelloHello'. This is a fundamental string operation defined in Python's sequence protocol.

Answer analysis

Option-by-option breakdown

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

  • ✗

    'Hello3'

    Why it's wrong here

    This option assumes the multiplication operator concatenates the integer as a raw character, but Python does not implicitly convert integers to strings during arithmetic. The expression 'Hello' * 3 uses the repetition operator, which repeats the entire string operand, not appends a digit. To get this result you would need explicit conversion, such as 'Hello' + str(3).

  • ✓

    'HelloHelloHello'

    Why this is correct

    In Python, the asterisk operator, when applied to a string and an integer, repeats the string the specified number of times. So 'Hello' * 3 evaluates to 'HelloHelloHello' by concatenating three identical copies of the original string in sequence. This is a core feature of sequence types, and the result is always a single new string of length equal to the original length multiplied by the integer.

  • ✗

    'Hello Hello Hello'

    Why it's wrong here

    Selecting this output would require the repetition operator to automatically insert a space between copies, but Python's * does no such thing. It performs plain concatenation of the same string object repeatedly, with no added separators or formatting. To get spaces, you would need to incorporate a space into the string itself, as in 'Hello ' * 3.

  • ✗

    TypeError

    Why it's wrong here

    A TypeError would occur for invalid operand types like string + int or string * float, but string * int is a well-defined operation in Python. The repetition operator is specifically designed for sequence types to accept an integer multiplier, so no exception is raised. For a negative integer, the result is just an empty string, still not an error.

About these practice questions

Courseiva writes every PCAP question from scratch — 421 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 PCAP 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 PCAP exam.