In Scratch, operator blocks are blocks of code that perform mathematical operations such as addition, subtraction, multiplication, and division. You can use operator blocks to perform calculations and make decisions based on the result of those calculations.
Here are some examples of operator blocks in Scratch:
Operator blocks are an essential part of programming in Scratch, and they allow you to perform calculations and make decisions based on those calculations. You can use them to create games, animations, and other interactive programs.
The block adds two values and reports the result. Numbers can be typed directly into the block, or Reporter Blocks can be used instead.
This block can be stacked inside itself; this can be used to insert more numbers.
The block subtracts the second value from the first and reports the result.
The block multiplies the two values and reports the result.
The block divides the second value from the first and returns the result. If the first value is not divisible by the second, the reported value will have decimals.
Note that dividing by 0 in the inline editor will return infinity.
The block chooses a pseudo-random number from the first given number to the second, including both ends. If both numbers have no decimal places, it will report an integer. For example, if a 1 and a 3 were entered, the block could return a 1, 2, or 3. If any of the numbers have a decimal point, even .0, it reports a number with one decimal. For example, if 0.1 and 0.14 were given, the output will be 0.1, 0.11, 0.12, 0.13 or 0.14.
The block checks if the first value is greater than the other value. If the second value is less, the block returns true , otherwise it returns false.
The block checks if the first value is less than the second value. If it is less, the block returns true; otherwise, it returns false. This block also works with letters, as well as numbers. In Scratch, the letters at the top of the alphabet (eg a, b, c) are worth less than the letters at the end (eg x, y, z).
The block checks if the first value is equal to the other value. If the values are equal, the block returns true; otherwise, false. This block is not case sensitive.
The block joins two boolean blocks, they must be true to return true. If they are both true, the block returns true . if they are not all true or none true, it returns false.
The block joins two boolean blocks so that one of them can be true to return true — if at least one of them is true, the block returns true; if any of them is not true, it returns false.
The block checks if the boolean it contains is false. If false, the block returns true. If the condition is true, it returns false.
The block concatenates, or “connects” the two values together and reports the result
– For example, if “apple” and “banana” were put in the block, it would report “applebanana”.
The block signals the specified character of the given text.
Even though the block says “letter”, it will report all characters, including letters, numbers, symbols, and even spaces.
The block indicates the number of characters that the given string contains.
The block reports the division remainder when the first value is divided by the second. For example, when 10 is put in the first entry and 3 in the second, the block will report 1; 10 divided by 3 gives a remainder of 1.
The block rounds the given number to the nearest integer. It follows standard rounding rules; decimals greater than or equal to 0.5 are rounded up, while decimals less than 0.5 are rounded down.
The block performs a specified function on a given number and reports the result. The function can be changed by clicking the down arrow and selecting a new function from the drop-down menu.