Question Detail

COS 102 lecture 4 Objective Question

Question

What is the preferred style for handling multi-line expressions in Python?
Options
A Using a backslash (\) at the end of each line.
B Wrapping the expression inside parentheses, braces, and brackets.
Correct Answer
C Indenting each subsequent line by four spaces.
D Ending each line with a semicolon to indicate continuation.
Correct Answer

Option B is the correct answer.

Detailed Explanation

Page 22 states: 'To break a long statement over multiple lines, you can wrap the expression inside parentheses, braces, and brackets. This is the preferred style for handling multi-line expressions.' While backslash is mentioned as another way, it's not the 'preferred' one for expressions.

Hint

Check the 'Multi-line Statements' section on page 22 for the 'preferred style'.

Question Info