Question Detail

COS 102 Python strings Objective Question

Question

What is the output of the following Python expression: "Hello" + "World"?
Options
A "Hello World"
B "HelloWorld"
Correct Answer
C "Hello, World"
D An error due to missing space.
Correct Answer

Option B is the correct answer.

Detailed Explanation

Based on the 'No Space' Rule (page 6), the '+' operator does not automatically add spaces. Therefore, "Hello" and "World" will be joined directly, resulting in "HelloWorld".

Hint

Remember the 'No Space' Rule when concatenating strings.

Question Info