Question Detail

COS 102 Python strings Objective Question

Question

What is the output of the following Python code snippet?
name = "Alice" + " " + "Smith"
print(name)
Options
A "AliceSmith"
B "Alice Smith"
Correct Answer
C "Alice Smith "
D "Alice_Smith"
Correct Answer

Option B is the correct answer.

Detailed Explanation

The code concatenates "Alice", a space character " ", and "Smith". The space is explicitly added, resulting in "Alice Smith" (page 6).

Hint

Recall the 'No Space' rule and how explicit spaces are handled during concatenation.

Question Info