What does the Python expression `'abc' * 3` evaluate to?

Answer and explanation

Correct answer: B. 'abcabcabc'

  1. Step 1: In Python, the `*` operator applied between a sequence (such as a string or list) and an integer performs sequence repetition.
  2. Step 2: Repeating `'abc'` 3 times produces the concatenated string `'abcabcabc'`.
Answer
'abcabcabc'.
Why not the others: `['abc', 'abc', 'abc']` is list repetition `['abc'] * 3`; `'abc3'` is string concatenation with `'3'`; repeating strings with integers does not raise a TypeError.

Practise more Algorithms and Python Programming.

Free questions with an explanation for every one, and full timed EmSAT Achieve (UAE) mock tests.