Question Detail

COS 102 lecture 4 Objective Question

Question

How can a long Python statement be broken across multiple lines, according to the document?
Options
A By ending each line with a semicolon (;).
B By enclosing the expression in parentheses, braces, or brackets, or using a backslash at the end of the line.
Correct Answer
C By using a special 'newline' keyword.
D Python statements cannot span multiple lines.
Correct Answer

Option B is the correct answer.

Detailed Explanation

Page 22 explains, 'To break a long statement over multiple lines, you can wrap the expression inside parentheses, braces, and brackets.' It also mentions, 'Another way to wrap multiple lines is by using a backslash () at the end of every line to indicate line continuation.'

Hint

Check the 'Multi-line Statements' section on page 22 for methods to extend statements.

Question Info