Skip to content
Marlbridge

Revision Notes

IB DP Computer Science B.2: Programming – Revision Notes

Recall notes on IB DP Computer Science B.2 Programming, the largest SL sub-topic: control structures, data, modularity, pseudocode design, testing and Paper 2.

Level
IB
Topic
B.2 – Programming
Updated

Aligned to International Baccalaureate IB Diploma Programme Computer Science (DP Computer Science), First assessment 2027. Official subject brief .

Found an error? Report a correction.

B.2 Programming is the largest single sub-topic in the entire DP Computer Science syllabus at SL (40 hours), and remains large at HL (42 hours), as set out in the full syllabus guide. These notes work through the skills this sub-topic actually tests, alongside the subject overview and assessment revision notes already on the site.

Why B.2 sits inside computational thinking, not apart from it

B.1 Computational thinking establishes a specify-decompose-abstract-test process that is meant to be applied while programming, not learned separately from it. Revising B.2 in isolation – purely as syntax recall – misses what the syllabus actually rewards: being able to decompose a described problem into smaller, programmable steps, and to test a solution systematically rather than only running it once and checking the output looks plausible.

Core programming constructs to revise

Whichever language your course uses (Python or Java), the underlying constructs examined are the same:

  • Sequence, selection, iteration – the three basic control structures every program is built from: executing instructions in order, branching based on a condition (if/else), and repeating a block of instructions (for/while loops).
  • Data types and structures – primitive types (integer, real/float, boolean, character/string) and simple structures such as one-dimensional and two-dimensional arrays/lists, and how to choose an appropriate structure for a given problem.
  • Modularity – breaking a program into functions/procedures with defined inputs and outputs, which is the direct programming expression of B.1’s “decompose” step.
  • File and data handling – reading from and writing to files, and validating input, which matters for any solution that needs to persist or check data rather than just process it in memory once.

Pseudocode and program design

Before writing code, the syllabus expects students to be able to represent a solution’s logic in pseudocode or a flowchart-style design. Revise by practising converting a described real-world problem directly into pseudocode steps, then only afterwards translating that pseudocode into actual Python or Java syntax – this two-step habit is exactly what B.1’s computational thinking process asks for, and it is a more reliable way to avoid logic errors than writing code directly from a problem description.

Testing and debugging

A program that runs without crashing is not the same as a program that is correct. Revise the distinction between different kinds of test data: normal (typical, expected values), boundary (values at the very edge of what is valid), and erroneous (invalid values the program should reject or handle gracefully). A well-designed test plan checks all three categories against a defined set of expected outcomes before a solution is considered complete. Debugging skills – tracing through code step by step to find where actual behaviour diverges from expected behaviour – are examined alongside writing code, not treated as a separate topic.

A chart with three lanes sharing one number scale from −20 to 160, for a program that accepts exam scores from 0 to 100. The valid range 0 to 100 is shaded. Normal data: 75, accepted. Boundary data: 0 and 100, the extreme valid values at each edge, both accepted. Erroneous data: −5 and 150, outside the range, which should be rejected with an error message. Testing only a normal value does not show that the edges and invalid input are handled.
Normal, boundary and erroneous test data for a score from 0 to 100.

Connecting B.2 to the computational solution (internal assessment)

The 35-hour computational solution internal assessment is where B.2’s skills are applied at full scale: designing, building and documenting a solution to a real-world problem the student defines. Because the IA is scored partly on the quality of design and testing documentation, not just on whether the final program works, practising writing a clear test plan and recording actual test results (not just “it worked”) during any programming practice across the course builds a habit that pays off directly when the IA itself is due.

How B.2 is examined on Paper 2

Paper 2 draws on Theme B, including B.2 and B.3 object oriented programming at both levels, and, for HL only, B.4 abstract data types. Candidates answer in Java or Python. Expect a mix of code-reading questions (predicting what a given piece of pseudocode or code outputs), code-writing questions (producing a short program or function to a specification), and questions asking you to identify or fix an error in given code. Because code-reading and code-writing draw on the same underlying fluency, practising both – not just writing your own programs from scratch – is worth building into revision time specifically.

Self-test

  1. Name the three basic control structures every program is built from.
  2. What is the purpose of breaking a program into functions/procedures (modularity), and which step of the computational thinking process does this correspond to?
  3. Name the three categories of test data a test plan should include, and give a one-line description of each.
  4. Why does the syllabus expect pseudocode or a design representation before code is written, rather than code written directly from a problem description?
  5. Give one reason B.2’s skills matter directly for the computational solution internal assessment, beyond simply “you need to be able to code.”

Answers: 1. Sequence, selection and iteration. 2. It breaks a program into smaller units with defined inputs and outputs, making the program easier to build, test and understand; it corresponds to the “decompose” step of computational thinking. 3. Normal (typical, expected values), boundary (values at the very edge of validity), and erroneous (invalid values the program should reject or handle gracefully). 4. Because designing the logic first, separately from syntax, reduces logic errors and directly practises the specify-decompose-abstract-test process the whole course is built around, rather than conflating problem-solving with syntax recall. 5. The IA is scored partly on the quality of design and testing documentation, not just on whether the final program runs, so a habit of writing clear test plans and recording real test results (built through B.2 revision) pays off directly in the IA’s assessment criteria.

Four steps in order: problem description, pseudocode or flowchart, Python or Java code, then a test plan and a run. A dashed copper arrow that skips the design step and goes straight from the problem to code is crossed out: writing code directly from a problem description increases the risk of logic errors. A strip at the top lists the B.1 process, specify, decompose, abstract, test, which is applied while programming.
Design in pseudocode or a flowchart first, then write code, then test; skipping the design raises the risk of logic errors.

Frequently asked questions

How many teaching hours is B.2 Programming in IB Computer Science? B.2 Programming is 40 hours at SL, the largest single sub-topic in the syllabus at that level, and 42 hours at HL.

Which programming languages are used in IB DP Computer Science? The course is studied in Python or Java, and candidates answer Paper 2 in Java or Python.

What does Paper 2 cover in IB Computer Science? Paper 2 draws on Theme B, including B.2 programming and B.3 object-oriented programming at both levels, and B.4 abstract data types at HL only.

Why should you write pseudocode before code? Designing the logic first, separately from syntax, reduces logic errors and practises the specify, decompose, abstract and test process the course is built around.

Official syllabus

International Baccalaureate Organization, Diploma Programme Subject Brief – Sciences: Computer Science, first assessment 2027, (c) 2024 – the same source already cited by the full syllabus guide, which first reproduced B.2’s teaching hours and its place within Theme B from it.

Three small flowcharts. Sequence: Step 1, Step 2 and Step 3 run in order. Selection: a condition is tested; if yes, block A runs, if no, block B runs, and then the program carries on. Iteration: a block is repeated, and after each pass the program asks whether to go again; if yes it loops back, if no it carries on.
Sequence, selection and iteration are the three basic control structures.
Four primitive types with example values: integer 42, real or float 3.5, boolean True, character or string "Hi". A one-dimensional array of five values 12, 7, 31, 5, 20 with indexes 0 to 4, where scores[2] is 31. A two-dimensional array with three rows and four columns, where grid[1][2], row 1 and column 2, is 2. The values are illustrative.
Primitive types plus one- and two-dimensional arrays.
A problem is broken into three functions, each with defined inputs and outputs, as the programming form of the decompose step. 1: get_score takes nothing and returns a score. 2: check_score takes the score and returns whether it is valid. 3: show_result takes the score and the validity and returns a message. Running with a score of 75 gives the message Score 75 accepted. The function names and the 0 to 100 rule are illustrative.
Functions with defined inputs and outputs are the programming form of decomposing a problem.
An illustrative loop meant to add the numbers 1 to 4 but written to stop at 3. A trace table compares the total after each pass for the code and for the plan: after i=1 both give 1, after i=2 both give 3, after i=3 both give 6, but on pass 4 the code has already ended while the plan reaches 10. The output is 6 from the code and 10 expected. Tracing shows exactly where actual behaviour diverges from expected behaviour.
Tracing shows exactly where actual behaviour diverges from expected behaviour.

Related resources

Get free revision emails (optional)

Occasional emails with practice questions, worked explanations and links to free resources for the qualification and subjects you choose. No spam, and you can unsubscribe from any email. The free tools on this site never need an email.

“International Baccalaureate” and “IB” are trademarks of the International Baccalaureate Organization. Marlbridge is not affiliated with or endorsed by the IB.