Skip to content
ExamSpine

B2.1 Programming fundamentals: notes and practice

B2.1 covers the basics every program needs: variables and data types, scope, operators, type conversion, string handling, exceptions, input validation, debugging and testing.

Paper 2SL and HL62 practice questions

What you need to know

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

  • Declare and assign variables of the common primitive types
  • Choose an appropriate data type for a given value and explain why
  • Distinguish local from global scope and predict which value a name refers to
  • Trace a program by hand and record variable values at each step in a trace table
  • Apply arithmetic, comparison and logical operators correctly, including operator precedence
  • Convert between data types explicitly and explain when conversion loses information
  • Extract a substring from a string by position
  • Manipulate strings by concatenating, searching, replacing and changing case
  • Split a string on a delimiter and rejoin parts
  • Explain what an exception is and when a program should handle one
  • Write code that catches an exception and recovers, rather than crashing
  • Validate input so that bad data is rejected before it causes an error
  • Distinguish syntax, runtime and logic errors and identify which one a described failure is
  • Debug a program using tracing, test output and breakpoints, and explain the fix
  • Design test cases including normal, boundary and invalid inputs

Learn it

Practice questions

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

Exam tips for B2.1

  • Trace tables are a common Paper 2 skill. Practise them until each row is automatic.
  • Know the difference between syntax, runtime and logic errors, with an example of each.
  • When designing tests, include normal, boundary and invalid inputs.

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.