← IB Computer Science

Trace tables and errors: IB Computer Science practice

Follow code and find the bugs. 12 questions in the style of the IB Computer Science exam.

Sample questions

What is a trace table used for?

  1. To store data permanently
  2. To record the values of variables as an algorithm is followed step by step
  3. To translate Python into machine code
  4. To draw the user interface

The program below should read whole numbers until 0 is entered and then print the mean of those numbers, rounded to 1 decimal place. It contains a logic error. Write a corrected version. You can assume at least one number is entered before the 0.

Explain the difference between a syntax error and a logic error. Give an example of each.