Practice Flashcards
Flip to reveal answersWhat is the difference between an else-if chain and separate ifs?
Track your progress — Sign up free to save your progress and get smart review reminders based on spaced repetition.
All 5 Flashcards — Selection
Sign up free to track progress and get spaced-repetition review schedules.
Question
What is the difference between an else-if chain and separate ifs?
Answer
A chain runs exactly one branch and skips the rest once a match is found. Separate ifs test every condition, so several may run or none. Use a chain for mutually exclusive cases and separate ifs for independent ones.
Question
Why must a range chain be ordered narrowest first?
Answer
The chain stops at the first true test. If mark >= 50 is tested before mark >= 70, every mark of 70 or more matches the first test, so the later branch is unreachable.
Question
What do and, or and not do?
Answer
and requires both sides to be true; or requires at least one; not reverses the result. They are the same logic as the AND, OR and NOT gates, with the same truth tables.
Question
What is wrong with 'if day == "Sat" or "Sun"'?
Answer
The second half is a bare piece of text rather than a comparison, and non-empty text counts as true — so the whole condition is always true. Each side of an or must be a full comparison.
Question
What is the difference between == and =?
Answer
== compares two values and produces a Boolean; = assigns a value to a variable. Writing = where == belongs is a classic error.
Read the notes
Full study notes for Selection
Topic 6.3 hub
Programming constructs
More from Topic 6.3
All flashcards in this topic
Computer Science exam skills
Paper structures & tips
Track your progress with spaced repetition
Sign up free — Aimnova tells you exactly which cards to review and when, so you remember everything before your IB exam.
Start Free