Math Operators

The dimension of Math Operators measures the use of mathematical operators and functions in your projects. These operators are essential for performing calculations, making decisions based on numerical values, and manipulating data. Mastery of these operators allows you to create more dynamic and interactive projects in Scratch.

If you get 1 point...

At the most basic level, you can use arithmetic operators to perform simple calculations. These include addition, subtraction, multiplication, and division. Here's a basic example showing these operators in use:

                    when green flag clicked
                    set [result v] to ((5) + (3))
                    say (result) for (3) secs
                    set [result v] to ((10) - (2))
                    say (result) for (3) secs
                    set [result v] to ((4) * (2))
                    say (result) for (3) secs
                    set [result v] to ((8) / (2))
                    say (result) for (3) secs
                

In this example, each arithmetic operation is executed sequentially, and the result is displayed on the screen. This demonstrates basic arithmetic calculations using Scratch's mathematical blocks.

If you get 2 points...

Building on basic arithmetic, you can use comparison operators to perform more complex operations. These operators include greater than, less than, and equal to. They are useful for making decisions based on numerical values. Here's an example:

                    when green flag clicked
                    set [number1 v] to (5)
                    set [number2 v] to (8)
                    if <(number1) < (number2)> then
                    say [Number1 is less than Number2] for (3) secs
                    else
                    say [Number1 is not less than Number2] for (3) secs
                    end
                    if <(number1) = (5)> then
                    say [Number1 equals 5]
                    end
                

In this example, the program uses comparison operators to check if one number is less than another and to verify if a number equals a specific value. This allows for conditional logic based on numerical comparisons.

If you get 3 points...

Beyond basic arithmetic and comparison, Scratch allows for more advanced string manipulations using operators for handling text. These include joining strings, finding the length of a string, and checking if a string contains another string. Here's how you can use these string operators:

                    when green flag clicked
                    set [text1 v] to [Hello]
                    set [text2 v] to [World]
                    set [combinedText v] to (join (text1) (text2))
                    say (combinedText) for (3) secs
                    set [textLength v] to (length of (combinedText))
                    say (textLength) for (3) secs
                    if <(combinedText) contains [Hello]> then
                    say [Text contains 'Hello'] for (3) secs
                    else
                    say [Text does not contain 'Hello'] for (3) secs
                    end
                

In this example, we demonstrate how to concatenate strings, find the length of the concatenated string, and check if a string contains a specific substring. These operations are useful for manipulating and processing text data in your Scratch projects.

If you get 4 points...

For advanced projects, you can use trigonometric functions to perform calculations involving angles. Scratch supports functions for cosine, sine, and tangent, which are useful for more complex mathematical computations and animations. Here's an example of how to use these trigonometric functions:

                    when green flag clicked
                    set [angle v] to (45)
                    set [cosineValue v] to (cos (angle))
                    say (join [Cosine of ] (angle))
                    say (cosineValue) for (3) secs
                    set [sineValue v] to (sin (angle))
                    say (join [Sine of ] (angle))
                    say (sineValue) for (3) secs
                    set [tangentValue v] to (tan (angle))
                    say (join [Tangent of ] (angle))
                    say (tangentValue) for (3) secs
                


In this example, the program calculates the cosine, sine, and tangent of a given angle and displays the results. This demonstrates the use of trigonometric functions to perform advanced mathematical operations.