aimnova.
DashboardMy LearningPaper MasteryStudy Plan

Aimnova site navigation

Stay in the loop

Get the latest study resources and updates

New features, study tips and exam insights — straight to your inbox.

IB Diploma

  • IB Past Papers
  • IB Study Notes
  • IB Question Bank
  • IB Mock Exams
  • IB Revision

IB Subjects

  • IB Math AA
  • IB Math AI
  • IB Economics
  • IB Business Management
  • IB Physics
  • IB Biology
  • View all IB subjects→

IB Past Papers

  • IB Math AA HL Past Papers
  • IB Math AA SL Past Papers
  • IB Math AI HL Past Papers
  • IB Math AI SL Past Papers
  • IB Economics HL Past Papers
  • IB Economics SL Past Papers
  • IB ESS Past Papers
  • View all past papers→

Study Resources

  • Study Notes
  • Question Bank
  • Mock Exams
  • Flashcards
  • Revision Guide
  • Exam Skills
  • Command Terms
  • Grade Calculator
  • Exam Timetable 2026

Aimnova

  • Features
  • Pricing
  • For Schools
  • For Parents
  • About Us
  • Blog
  • Contact
aimnova.

AI-powered study platform for smarter revision, past-paper analysis and examiner-style feedback.

TermsPrivacyCookies·© 2026 Aimnova. All rights reserved.8afc4e3

Aimnova is not affiliated with or endorsed by the International Baccalaureate Organization (IB).

NotesComputer Science HLTopic 6.3Selection
Back to Computer Science HL Topics
6.3.25 min read

Selection (Computer Science HL)

IB Computer Science • Unit 6

Your first topic is free to keep

Know exactly what to write for full marks

Practice with exam questions and get AI feedback that shows you the perfect answer — what examiners want to see.

Start Free

Contents

  • Choosing which lines run
  • Order, and separate ifs
  • Combining conditions
  • Exam-style question
The big idea: Selection runs one block of code instead of another, depending on a condition.

The condition is always a Boolean — it works out to True or False, and nothing else.
An else-if chain stops at the first match: Once a branch is taken, the rest are skipped entirely.

So a mark of 75 gives "A" and never reaches the 60 test — which is exactly why the order of the tests matters.

Free preview

This is the free notes preview

You're reading the free notes. Aimnova Pro unlocks the full study experience — and you can try it with your first topic free to keep:

  • FlashcardsLock in vocabulary and key terms with spaced repetition.
  • Practice questionsAnswer exam-style questions and get instant AI marking.
  • Mock exams & past-paper vaultSit full mocks and see exactly how examiners award marks.
  • Personalised study planA daily plan built around your exam date and weak areas.
Start Studying Free Full access to Aimnova Pro · cancel anytime

One else-if chain

  • Exactly one branch runs
  • Later tests are skipped once a match is found
  • Right when the cases are mutually exclusive — one grade per mark
  • Faster: it stops as soon as it knows

Separate ifs

  • Every condition is tested
  • Several may run, or none
  • Right when the cases are independent — a discount and free delivery
  • Using separate ifs for exclusive cases is a common bug
Order the tests from the narrowest: In a chain of ranges, start with the most restrictive and work outwards.

Testing mark >= 50 first catches every passing mark, so nothing after it can ever run. This is the single commonest selection bug.

Practice with real exam questions

Answer exam-style questions and get AI feedback that shows you exactly what examiners want to see in a full-marks response.

Try Practice FreeYour first topic is free to keep • No credit card required

Relational operators

  • == equal · != not equal
  • < and > · <= and >=
  • == compares; = assigns — mixing them is a classic error

Boolean operators

  • and — both must be true
  • or — at least one must be true
  • not — reverses it
  • The same logic as the AND, OR and NOT gates in Unit A1

Writing them well

  • Brackets make the grouping obvious, even when not required
  • and binds tighter than or, so a or b and c is a or (b and c)
  • If you have to work it out, add the brackets
Each side of or must be a full test: day == "Saturday" or "Sunday" does not mean what it looks like.

The second half is just a piece of text, which counts as true — so the whole condition is always true. Write the comparison out on both sides.

How this is tested — you must pick the right structure and order the conditions so each can actually be reached. It comes up two ways:

Paper 2 — working with code

  • Construct selection for a described rule, 3-5 marks
  • Trace which branch runs for given values
  • Find the error in a chain of conditions

Paper 2 — the algorithmic-thinking question

  • Decide from a rule in words with no code shown
  • Explain why a branch is unreachable
The classic trap: Ordering a range chain from the widest test first. If mark >= 50 comes first, every passing mark stops there and no later branch is ever reachable — even though the code looks right.
IB-style questionConstruct[5 marks]

A shop gives 20% off orders over £100, 10% off orders over £50, and free delivery on any order over £30. Write the selection structure.

Model answer plan

See the mark-by-mark plan — for / against / judgement, with marking guidance — in study mode.

Claim your free topic

Try an IB Exam Question — Free AI Feedback

Test yourself on Selection. Write your answer and get instant AI feedback — just like a real IB examiner.

the term selection. [1 mark]

Related Computer Science HL Topics

Continue learning with these related topics from the same unit:

6.1.1Variables and data types
6.1.2Substrings
6.1.3Exception handling
6.1.4Debugging
View all Computer Science HL topics

Improve your exam technique

Command terms, paper structure, and mark-scheme tips for Computer Science HL

Previous
6.3.1Sequence
Next
Loops6.3.3

24 questions to test your understanding

Reading is just the start. Students who tested themselves scored 82% on average — try IB-style questions with AI feedback.

Start FreeView All Computer Science HL Topics