Question Detail

COS 102 If staments Objective Question

Question

What is crucial for Python to understand which code belongs to an if block?
Options
A Using curly braces {}
B Using parentheses ()
C Correct indentation (whitespace)
Correct Answer
D Adding comments at the end of each line
Correct Answer

Option C is the correct answer.

Detailed Explanation

Page 6, 'The 'If' Syntax', under 'Indentation', states: 'The 'action' must be spaced in!' Page 15, 'Mistake #2: Colon & Indent', further clarifies: 'Indentation: Python uses whitespace to know what code belongs to the if block.'

Hint

Python is known for its reliance on a specific visual structuring element for code blocks.

Question Info