Question Detail

COS 102 Python strings Objective Question

Question

What is the output of the Python expression "Go!" * 2?
Options
A "Go!Go!"
Correct Answer
B "Go! 2"
C "Go! Go!"
D An error
Correct Answer

Option A is the correct answer.

Detailed Explanation

The '*' operator performs string repetition. Multiplying 'Go!' by 2 results in the string 'Go!' repeated twice, yielding 'Go!Go!'.

Hint

This is an example of string repetition. Think about the example given in the 'Predict the Output!' section.

Question Info