Back to Topic 6.3 — Programming constructs
6.3.2Computer Science SL5 flashcards

Selection

Practice Flashcards

Flip to reveal answers
Card 1 of 56.3.2
6.3.2
Question

What is the difference between an else-if chain and separate ifs?

Click to reveal answer

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.

Card 1comparison

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.

Card 2concept

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.

Card 3definition

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.

Card 4concept

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.

Card 5comparison

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.

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