← IB Computer Science

Testing: IB Computer Science practice

Normal, boundary and erroneous data. 10 questions in the style of the IB Computer Science exam.

Sample questions

A program accepts ages from 13 to 19 inclusive. Which of these is boundary test data?

  1. 15
  2. 19
  3. "abc"
  4. 50

This code tests a validation function with some test data. What does it print?

def valid_mark(m):
    return 0 <= m <= 50

for test in [25, 0, 50, 51, -1]:
    print(test, valid_mark(test))

A loop that should add up a list gives the wrong total. Which debugging technique would best show how the total changes on each pass?

  1. Add a print statement inside the loop showing the loop variable and the total
  2. Rename the variables to shorter names
  3. Add a comment above the loop
  4. Run the program again with the same input and hope it changes