# Randomisation

You can add a script to your exercise to define random variables. Use these variables in the instructions and interactions of your exercise.

A basic randomised algebra interaction

This question is the randomised variant of this static algebra interaction. Create a copy of this basic exercise and use the below instructions to update the interaction to make it randomised.

Use the dropdown on the top left to add a script to the exercise.

We will create a script that defines a quadratic equation with integer solutions.

The scripting functionality of AlgebraKiT supports a rich set of commands and programming features. For now, the most important thing is that we have defined the variable expr that represents the random quadratic expression.

In the instruction, change the equation as follows:

In the task definition, update the field for the relation.

Your first randomised exercise is ready! Now click Run.

The following exercise is generated from this example. Refresh the page to see a different instance.

If you want to learn more about scripting then read the section ‘Scripting concepts’ below.

Scripting concepts

## Variable definitions

A variable is a sequence of symbols. Allowed symbols are letters, digits, and the underscore. The first symbol must be a letter.

You can create a definition using the symbol :=.

my_variable:= 2x^2-3x+4

Note that the definition does not have to be a number, but can be any mathematical expression.

## Operators

The following table lists the basic math operators

1. The multiplication symbol is optional. So 3x is interpreted as 3*x. However, ab is interpreted as the variable ‘ab’ and not as a*b. You should add a times symbol or an extra space if you intend the multiplication.
2. The relational symbols =, >, <, <=, and >= are used to construct mathematical relations without evaluating them. E.g. x^2=2x is an equation, whereas 2==3 is an expression that will be evaluated as False.

## Constructions

The scripting language of AlgebraKiT defines the following constructions to build expressions:

Some examples:

## Some essential commands

The complete list of commands can be found in the Syntax guide. The following table lists the commands that are used most often.