⭐ 1.5.2 Subtraction
Subtraction is addition in reverse. The or “() - ()” block in Scratch subtracts a number from another and returns the result.
Activity: Subtraction operator
You are going to subtract a value stored in “myNumber2” from the value stored in “my Number”, then the puppy tells the result. Remember that “my Number” and “myNumber2” were created in activity 1.1.
To create a Subtraction Puppy project, follow these steps:
- Select File ⇒ File and then Save as a Copy from the top menu.
An exact copy of the project is created, with the title changed to Addition Puppy copy.
- Change the title of the project to Subtraction Puppy.
- Drag the block out of the block in the Scripts Area, as shown below:
- Drag a block from the “Operators” Block Palette and drop it into the block.
- Drag the “my Number” block from the block in the Scripts Area and place it into the first space in the block.
- Drag the myNumber2 block from the block in the Scripts Area and place it into the second space in the block.
- Right-click the empty block and select Delete.
Your script should now look like Figure 25.
Figure 25: Script for subtraction
Test the Subtraction Puppy by clicking the Green Flag and dragging the variable sliders on the Stage. The puppy instantly executes the subtractions and shows the answer, as you can see below:
Figure 26: The Subtraction Puppy result