Question Detail

COS 102 Python strings Objective Question

Question

When using the repetition operator ('*') with a string in Python, what type of value must follow the operator to specify the number of repetitions?
Options
A Another string
B A floating-point number
C A boolean value
D An integer
Correct Answer
Correct Answer

Option D is the correct answer.

Detailed Explanation

The 'Repetition' section (page 7) states: 'We use the * operator followed by an integer.'

Hint

The document gives an example of `print(laugh * 3)`.

Question Info