Home › CS Olympiad › Computer Science › Booleans and Decisions › An elif statement is only legal when it directly…
An elif statement is only legal when it directly follows an if or another:
Aelse
Bwhile
Cprint
Delif
Answer & Solution
Correct answer: D. elif
1. elif is part of a chain, never alone.
2. It must attach to a previous test.
3. So it follows an if or another elif.
_Source: OpenStax Introduction to Python Programming, Chapter 4._
Related questions
A curve program uses two separate if statements and both run by mistake. The fix is to useMost Python operators are evaluated in which direction?The rule deciding order when two operators share a precedence level is:In Python the expression (1 + 2) * 3 evaluates to:In Python the expression 1 + 2 * 3 evaluates to:A program should act when a computer is switched off. The operator to use is:A concert lets in anyone in band or choir. The operator to use is:A club entry rule needs both age and ticket to be valid. The operator to use is: