How good is your Python 3 knowledge? Take our quiz to find out now.

Times Tables Trace Table

I want to share a programming activity with you which addresses several topics in the GCSE computer Science syllabus.

One of the challenges when following a syllabus with clearly delineated assessment objectives is that the knowledge required to become a competent programmer is deeply interconnected, and the various components rarely appear in isolation.

For example, the short program we are going to look at in this article is related to the following objectives from the Edexcel GCSE Computer Science Syllabus:

  • 1.1.2 understand how to create an algorithm to solve a particular problem, making use of programming constructs (sequence, selection, iteration) and using appropriate conventions (flowchart, pseudocode, written description, draft program code)

  • 1.1.5 Understand how to identify and correct errors in algorithms, including using trace tables

  • 2.1.6 be able to determine what value a variable will hold at a given point in a program (trace table)

  • 2.2.1 understand the structural components of a program (variable and type declarations, command sequences, selection, iteration, data structures, subprograms)

  • 2.2.2 be able to use sequencing, selection and iteration constructs in their programs

  • 2.4.1 understand how to write code that accepts and responds appropriately to user input

We are going to work our way up to writing a program which outputs a trace table for an algorithm which display a times table of the user’s choice. We will begin with some “warmup” exercises before attempting the full solution. Before looking at the solutions I have provided, have a go at the exercises using your preferred IDE (coding space).

Warmup Exercise 1: Write a Python program to print out all the values for the 5 times table up to 10 * 5.

Warmup Exercise 2: Now modify your program so the user can choose which times table to print.

Remember we need to use int to turn the input into a number

Warmup Exercise 3: Use tab characters \t to print the following line containing column headings:

table    index    value    OUTPUT

(Different editors may behave differently regarding their handling of tabs, so you may need to experiment with how many you use for your spacing.)

The main task: Put together all you have done so far and create a program that outputs the values for table index value OUTPUT at every step in the iteration (for loop).

The result should look something like this:

table   index   value   OUTPUT
6       1       6       6
6       2       12      12
6       3       18      18
6       4       24      24
6       5       30      30
6       6       36      36
6       7       42      42
6       8       48      48
6       9       54      54
6       10      60      60    

Good luck and make sure you have a good go at it by yourself before looking at the solution below.

I hope that was a useful and fun activity – let me know how you got on in the comments below.


Below are products related to this article, some of which may be affiliate links.

Sharing is caring!

One Reply to “Times Tables Trace Table”

Leave a Reply

Your email address will not be published. Required fields are marked *