Finding the Range of Numbers means finding what a list of numbers ranges from. This can be done by subtracting the lowest value in a list of numbers, from the highest value.

## Doing it in Scratch

### Method 1

For this tutorial the following variables and lists will be required:

Variables:

• Highest #

— Holds the value of the highest number

• Lowest #

— Holds the value of the lowest number

• Iterator

— A counter variable

• Range

Lists:

• List of Numbers

— The list in which all the values are kept

#### Step 1

This step finds the highest value in the list. To do this use this simple script:

```set [Iterator v] to 
set [Highest # v] to 
repeat (length of [List of Numbers v])
change [Iterator v] by (1)
if <(item (Iterator) of [List of Numbers v]) > (Highest #)> then
set [Highest # v] to (item (Iterator) of [List of Numbers v])
end
end
```

#### Step 2

This step finds the lowest value in the list. To do this, all that is needed is a slight alteration of the above script, by changing the > to a <, changing the variable, and setting the lowest number to the highest number.

```set [Iterator v] to 
Set [Lowest # v] to (Highest #)
repeat (length of [List of Numbers v])
change [Iterator v] by (1)
if <(item (Iterator) of [List of Numbers v]) < (Lowest #)> then
set [Lowest # v] to (item (Iterator) of [List of Numbers v])
end
end
```

#### Step 3

The final step simply subtracts the lowest value from the highest value, and sets the answer variable (Range) to that value.

```set [Range v] to ((Highest #) - (Lowest #))
``` Note: This method only works if the highest number is positive.

### Method 2

In this method, the first step is sorting the list. Then, add this script to the bottom:

```set [Range v] to ((item (last v) of [Text v]) - (item (1 v) of [Text v]))
```

Range will contain the range.