Question Detail

COS 102 If staments Objective Question

Question

In a Python if statement, what determines which code belongs to the conditional block?
Options
A Parentheses around the code
B Curly braces surrounding the code
C A specific keyword to start and end the block
D Whitespace (indentation) before the code
Correct Answer
Correct Answer

Option D is the correct answer.

Detailed Explanation

Page 15, 'Mistake #2: Colon & Indent', states: 'Indentation: Python uses whitespace to know what code belongs to the if block.'

Hint

This is a fundamental aspect of Python's structure, unlike many other programming languages.

Question Info