Operators: plus minus multiply divide
-
Prerequisite
Description
The Plus(+), Minus(-), Multiply(*) and Divide(/) blocks are Reporter Blocks in the Operators category.
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/963e3572-2e6f-41ad-9d1f-81688ade8af6.PNG" width="600" style="">
These blocks are used to Add, Subtract, Multiply and Divide two numbers. Since they are reporter blocks, the calculation results will be reported as the value of the block.
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/6d41b181-f2a2-4e7f-8202-2ce0d339eedd.gif" width="700" style="border-radius: 5px; border: 1px solid #29622d;">
Using Variables as Input
You can also use “variables” as input in these blocks. After assigning a value to a variable, you can place the variable inside the operator’s input box:
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/c9314b43-856d-447f-ab7f-b6a68edc65f0.gif" width="800" style="border-radius: 5px; border: 1px solid #29622d;">
Saving the Result in a Variable
You can store the result from the operation in a variable, then display that variable’s value in the stage window like this:
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/09c7eed1-6e43-49f6-b357-8c2e108cb67c.gif" width="800" style="border-radius: 5px; border: 1px solid #29622d;">
Nested Operator Blocks
You can also put an operator block inside the input box of another operator block to create “Nested Operators”. Note that the order of the nested operator blocks is important: For example, 1 + (3*2) and (1+3) * 2 will give different answers.
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/a266ec15-22e8-4156-851e-703251014110.gif" width="700" style="border-radius: 5px; border: 1px solid #29622d;">
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login