⭐ 1.5.2 Subtraction

View

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:

  1. 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.

 

  1. Change the title of the project to Subtraction Puppy.

 

  1. Drag the  block out of the  block in the Scripts Area, as shown below:

 

 

 

  1. Drag a  block from the “Operators” Block Palette and drop it into the block.

 

  1. Drag the “my Number” block from the  block in the Scripts Area and place it into the first space in the  block.

 

  1. Drag the myNumber2 block from the  block in the Scripts Area and place it into the second space in the  block.

 

  1. 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

Last modified: Thursday, 23 September 2021, 10:57 AM