1.5 Operators

View

The Operators Block Palette contains 18 blocks. All these blocks have one thing in common: they take one or more values and use them to return another value.

In programming, using values to produce other values is called performing an operation. The blocks that make operations possible are called “operators.”  Operations are specific tasks that work with values to produce results.

A simple example of an operator is a mathematical calculation (e.g. 1+3=4) or making a combination of words to form a sentence (e.g. “Hello” + “World” =  “Hello World”).

Figure 21: The operator blocks

 

Operators are powerful blocks. Understanding and mastering them is key to do all sorts of useful and essential things in your projects. Some things they make possible include:

●        Keeping track of the score or result

●        Joining words to change what sprites say

●        Making sprites move in a realistic way

●        Solving math problems

●        Checking answers of a quiz

●        Randomizing the positions and movements of obstacles and monsters in a game

Doing Maths with Scratch

You don’t need to be a math genius to write programs but knowing how to use the math operator blocks certainly makes you look like genius!  This section shows you how to use each operator and gives you some tips, tricks, and examples that you can use in your own projects.

Last modified: Tuesday, 21 December 2021, 3:37 PM