Times Table Tester

Do you have a younger brother or sister who is learning their times tables? Do you think that you could do with brushing up on your tables yourself? In this assignment you are going to write a program that will test users on their knowledge of the times tables and give them a score. If you missed the first assignment, click here for instructions on how to install Python. If you are unable to install Python then you can use an IDE such as use replit.com to run your programs on-line.

Related Links

There is a page on random numbers and how to scale them into the right range in the Mathematics section of this site. This will be the subject of a future lesson, but if you're feeling keen you could look ahead and also use the following command to jumble up the questions:

NB. Python has no native support for random numbers, so the above example will only work if you add from random import randint to the top of your program.

If you really want to practise your times tables, you might also like to try to the Visual Times Tables web-page that I created to help the children in my family.

Predict, Run, Investigate

Open and read the Times Table Tester - Starter program.

  1. What is the variable on line 1 for?
  2. Line 3 contains a mixture of variables and fixed text - can you see what it will print?
  3. What do you think will happen when you run the program?
  4. Could you update the program so that it counts from 2 to 12 instead of 0 to 9?
  5. Which two variables do you need to be able to calculate the correct answer on each line?
  6. Can you add the correct answer to each line, so that the two times table is printed?
  7. How would you print a different table?  Could you ask the user which one they want?

Modify

Take a copy of the Times Table Tester - Starter program and modify it so that:

  1. The user is asked ten questions from the times tables
  2. only questions from 2 x 2 up to 12 x 12 (i.e. you don't need 1 x 1 or anything bigger) are asked
  3. the user is told whether their answer is right or wrong
  4. the program keeps a score, and tells the user their score at the end
  5. it is clear and easy to use

The minimum output is the questions and the score, but you can add extra text to make it easy to understand.

Extension

If you found that quite straightforward, you could add some extra features. What about asking if they want another go, and then comparing their score with the previous one? There are lots of things that you could add to this program. You could use the random function to ask a questions at random, rather than asking them in order. How about making sure that the user doesn't get the same question twice in a row - or twice in a set of 10 questions? For a real challenge, how about displaying an array to represent the calculation, as I've done with the spots on my times table tester page.