Scratch Part 9: Maths

We can use the Operators area of Scratch to define some questions for a maths quiz.

The = operator is used to test for equality e.g. does 2 + 2 = 4?

The four basic operators are used with numbers or variables to perform calculations. These can be nested to form longer expressions.

Note that there are no brackets in Scratch but operator precedence can be enforced by use of expressions. For example, 2 + 2 x 2 is done by putting the 2 x 2 part in the right hand side of a + operation while (2 + 2) x 2 is done by putting the (2 + 2) part inside a + operation on the left side of the expression.

2 + 2 * 2:

(2 + 2) x 2:

The < and > operators are used to test for less than and greater than.

The pick random m to n control can be used to generate random numbers between m and n.

The function operator can be used to generate common functions such as square root.

The mod function is used to find remainders e.g. 5 mod 3 = 2.

The round function is used to round numbers to the nearest whole number.

You could use the ask command to create a test or you could use more graphical techniques by defining sprites that represent alternative answers. See some examples before creating your own.

Task 13: Maths Quiz

Create a Maths Quiz appropriate to the level of your class. Use the Ask command for your questions or set up sprites for alternative answers and the touching condition in Sensing to detect whether the user's sprite is touching an answer's sprite. Or use the when spriten clicked hat to allow the user to click on a sprite to select an answer.

Projectiles