Question 338 of 511
StringseasyMultiple ChoiceObjective-mapped

Quick Answer

The correct expression is 'Hello' * 3, which returns the string 'HelloHelloHello'. This works because in Python, the multiplication operator (*) acts as a string repetition operator when used between a string and an integer, effectively concatenating multiple copies of the original string. This behavior stems from Python's sequence protocol, where strings are treated as immutable sequences of characters, and the * operator is overloaded to support repetition for all sequence types. On the Certified Associate Python Programmer PCAP exam, this concept tests your understanding of operator overloading and sequence operations, often appearing in questions that ask you to predict output or identify valid syntax. A common trap is confusing the * operator with the + operator for concatenation, or forgetting that the integer must come after the string—though order doesn't matter here, 'Hello' * 3 and 3 * 'Hello' both work. To remember, think of the asterisk as a "copy machine" for strings: it prints the string as many times as the number you give it.

PCAP Strings Practice Question

This PCAP practice question tests your understanding of strings. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

Which of the following expressions returns the string 'Hello' repeated three times?

Question 1easymultiple choice
Full question →

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

'Hello' * 3

In Python, the multiplication operator (*) when used with a string and an integer performs string repetition. 'Hello' * 3 returns the string 'HelloHelloHello' by concatenating three copies of the original string. This is a core feature of Python's sequence protocol, where strings are sequences of characters.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Answer analysis

Option-by-option breakdown

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

  • 'Hello' * 3

    Why this is correct

    Repeats the string three times: 'HelloHelloHello'.

    Related concept

    Read the scenario before looking for a memorised answer.

  • 'Hello' + 3

    Why it's wrong here

    Cannot concatenate str and int, raises TypeError.

  • 'Hello' * '3'

    Why it's wrong here

    Cannot multiply string by string, raises TypeError.

  • 'Hello' * 3.0

    Why it's wrong here

    Cannot multiply string by float, raises TypeError.

Common exam traps

Common exam trap: answer the scenario, not the keyword

The trap here is that candidates may think the + operator can coerce types or that string multiplication accepts any numeric type, but Python strictly requires an integer for the repetition count and raises a TypeError for floats or strings.

Detailed technical explanation

How to think about this question

Under the hood, Python's string repetition is implemented via the __mul__ method on the str class, which expects an integer operand. When you write 'Hello' * 3, Python internally allocates a new string of length len('Hello') * 3 and copies the characters. This is efficient for small repetitions but can be memory-intensive for very large multipliers. A real-world scenario is generating repeated separators like '-' * 80 to create a horizontal line in console output.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A cloud solutions architect for a retail company is evaluating services for a new workload. The correct answer here reflects best practice for the specific scenario described — not a general cloud recommendation. Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option. Cloud exam questions reward reading the constraint carefully: the same technology can be right or wrong depending on the use case.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related PCAP practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free PCAP practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this PCAP question test?

Strings — This question tests Strings — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: 'Hello' * 3 — In Python, the multiplication operator (*) when used with a string and an integer performs string repetition. 'Hello' * 3 returns the string 'HelloHelloHello' by concatenating three copies of the original string. This is a core feature of Python's sequence protocol, where strings are sequences of characters.

What should I do if I get this PCAP question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

1 more ways this is tested on PCAP

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. What is the result of the expression 'Hello' * 3?

easy
  • A.'Hello3'
  • B.'HelloHelloHello'
  • C.'Hello Hello Hello'
  • D.TypeError

Why B: The * operator on a string repeats the string the specified number of times. 'Hello' * 3 yields 'HelloHelloHello'.

Keep practising

More PCAP practice questions

Last reviewed: Jun 24, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

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.