Skip to content
ExamSpine

B2.3 Programming constructs: notes and practice

B2.3 is the core of programming: sequence, selection with if and else, loops that count or check a condition, nested loops and functions with parameters and return values.

Paper 2SL and HL70 practice questions

What you need to know

Our summary of the topic in our own words, not the IB guide.

  • Write a program whose statements run in the correct order to meet a stated objective
  • Write conditional statements using if, else if and else
  • Write nested and compound conditions correctly
  • Trace a program with branching and state which branch runs for given inputs
  • Write a count-controlled loop
  • Write a condition-controlled loop and avoid an infinite loop
  • Write nested loops, for example to process a two-dimensional structure
  • Trace a loop and state the number of iterations and the final values
  • Define a function with parameters and a return value, and call it
  • Explain the difference between a parameter and an argument, and between returning and printing
  • Decompose a long program into functions and explain the benefit of modularisation

Learn it

Practice questions

Original questions written for the 2027 course, marked as you go. Easiest first.

Exam tips for B2.3

  • Check loop boundaries carefully. Off-by-one errors are a very common mistake.
  • Know the difference between returning a value and printing it.
  • Break long answers into small functions. It is easier to write and to mark.

Updated 24 October 2026. Topic codes are used as labels. Everything on this page is written by ExamSpine and is not endorsed by the IB.