Question Detail

COS 102 Python strings Objective Question

Question

What will be the output of print("Go!" * 2) in Python?
Options
A "Go!Go!"
Correct Answer
B "Go! 2"
C "Go! Go!"
D "Go!Go! "
Correct Answer

Option A is the correct answer.

Detailed Explanation

The * operator performs repetition. Repeating the string "Go!" two times results in "Go!Go!" (page 7, 11).

Hint

The `*` operator, when used with a string and an integer, repeats the string.

Question Info