Question Detail

COS 102 6 lecture note; fundamentals of programming Objective Question

Question

In Python's conditional constructs (like if-elif-else), what is required at the end of each condition and else keyword?
Options
A A semicolon (;)
B A comma (,)
C A colon (:)
Correct Answer
D Nothing, it's optional
Correct Answer

Option C is the correct answer.

Detailed Explanation

Page 41 of the document, specifically in the diagram illustrating the if-elif-else syntax, clearly points out ': Colon Must'. This signifies that a colon is syntactically required after conditions (if, elif) and the else keyword.

Hint

Look at the Python syntax for conditional statements presented in the slides; there's a specific punctuation mark always present.

Question Info