Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

mQuest: Python Mathematics Question Generator

Generates multiplication and division questions in a variety of formats, e.g.

  • Multiplication questions (in order) e.g. 7 times tables
  • Multiplication questions (in mixed order) e.g. 9 times tables questions in random order
  • Mixed multiplication questions i.e. testing more than one times table at a time
  • Division questions (in mixed order) e.g. divide by 8 questions

As a bonus, to aid study it can generate a different set of questions for each day of the week.

Table of contents


This originally started off as a script I wrote to generate mathematical questions focused around multiplications and divisions, for my daughter to learn and practice her times tables (using pen and paper).

I decided it may be of use to others, and so, after some over-engineering, here we are!

Example outputs

11 x table questions:
 1 x 11 = 
 2 x 11 = 
 3 x 11 = 
12 x 11 = 
8 x table questions (shuffled):
 6 x 8 = 
 1 x 8 = 
12 x 8 = 
 5 x 8 = 
÷ (divide by) 4 questions:
 44 ÷ 4 = 
 36 ÷ 4 = 
  8 ÷ 4 = 
 32 ÷ 4 = 
Mixed multiplication questions:
 7 x 6 = 
 9 x 10 = 
12 x 8 = 
 6 x 3 = 


mQuest is designed to run on Python 3.7 or later, and has no dependencies (other than those in the Python standard library). To install, run the following at the command prompt:

git clone


mQuest can generate questions either by being run with its CLI from a command prompt, or by importing it as a python module and using it directly within your own script/program.

With CLI

Command line options:

You can list mQuest's options by running python mquest/ --help from the installation directory:

usage: [-h] -m {m,mm,d} -o OPERANDS [OPERANDS ...] [-s]
                 [-d {0,1,2,3,4,5,6}] [-f FILE]

mQuest: Python Mathematics Question Generator.

optional arguments:
  -h, --help            show this help message and exit
  -m {m,mm,d}, --mode {m,mm,d}
                        Mode, either: 'm' (multiplication), 'mm' (mixed
                        multiplication) or 'd' (division).
  -o OPERANDS [OPERANDS ...], --operands OPERANDS [OPERANDS ...]
                        The operand(s) to apply to the specified mode (used to
                        multiply or divide by). For mixed multiplications
                        specify multiple operands.
  -s, --shuffle         Shuffle order of generated questions (applies to
                        multiplication mode only).
  -d {0,1,2,3,4,5,6}, --start-day {0,1,2,3,4,5,6}
                        Start day, (0 for Monday, 1 for Tuesday, ..., 6 for
  -f FILE, --file FILE  If specified write to output file instead of printing
                        to stdout.

Command line examples:

Generate 7 times table questions:

> python mquest/ --mode m --operands 7
 1 x 7 =
 2 x 7 =
 3 x 7 =

Generate 8 times table questions, and mix order:

> python mquest/ --mode m --operands 8 --shuffle
 8 x 8 =
 3 x 8 =
 2 x 8 =

Generate divide by 9 questions:

> python mquest/ --mode d --operands 9
 63 ÷ 9 =
108 ÷ 9 =
 72 ÷ 9 =

Generate mixed multiplication questions (from 2, 3 and 5 times tables):

> python mquest/ --mode mm --operands 2 3 5
10 x 5 =
 5 x 3 =
 9 x 3 =
 1 x 2 =

Generate 12 times tables, for every day of the week starting Monday, and send output to file:

> python mquest/ --mode m --operands 12 --start-day 0 --file times_12_questions.txt
> cat times_12_questions.txt
 1 x 12 = 

 1 x 12 = 

 1 x 12 = 



As a module

mQuest code can also be used as a module, and imported into your own package.

General examples

Note: the examples in this section can be found in the file. To run the file as as script, use:

> python -m examples.examples

Importing mQuest as a module example:

from mquest import mquest

# Generate a raw list of ordered 11 times table questions
times_11_questions = mquest.generate_multiplications(multiplier=11)

# Format and print them, with a heading
print(mquest.format_questions(heading="11 x table questions",

# Generate a single set of 8 times tables questions, shuffle the order,
# format, and print
    heading="8 x table questions (shuffled)",

# Generate a single set of division by 4 questions in shuffled order,
# format, and print
    heading="÷ (divide by) 4 questions",

to generate a set of questions for each day of the week:

import calendar

from mquest import mquest # if not already imported

# Define list of study days (i.e. days to generate questions for),
# for each day of the week, starting on Friday
study_days = mquest.get_days_of_week(first_day=calendar.FRIDAY)

# Generate daily 3 times tables questions, in order, format, and print
# (for each day of the week)
for day in study_days:

# Generate daily, mixed, shuffled questions for 2, 3, 4, 5, 6, 8 & 10
# times tables, format, and print (for each day of the week)
for day in study_days:
        multipliers=[2, 3, 4, 5, 6, 8, 10]),

Generate files for ALL times tables and divisions

To generate separate question files (ordered times tables, unordered times tables and divisions), for each for each day of the week, for each number between 1-12, see the example found in

To run the file as as script, modify the following lines to define the first study day of the week (the day to start generating questions for) and the output path (where the generated files will be written):

# Define start day (of each week)
study_days = mquest.get_days_of_week(first_day=calendar.SUNDAY)

# Define path to write files to, and ensure it exists
output_path = pathlib.Path('output')

then use the following to generate the files:

> python -m examples.generate_all

which will generate 36 files in the specified output_path directory.


Contributions to improve mQuest are welcomed, in the form of suggestions, bug fixes, new features, or anything else you see fit. Please submit a pull request.


mQuest is licensed under the MIT License


No releases published


No packages published