- This article is about how numbers are used in programming. For the blocks that deal with numbers, see Operators Blocks.
Numbers are mathematical values that play a huge role in programming. In Scratch, they are used for optimizing and making algorithms function properly. Without numbers, addition, multiplication, etc. would not be possible. Numbers are also used as identifiers in Scratch, such as the (costume [number v])
block, which identifies the placement of a costume in a sprite.
Mathematical Functions
The following table lists various mathematical functions and how to perform them in Scratch; it is not inclusive to all functions:
Math Operations in Scratch | |
---|---|
Concept | Scripting |
addition | (() + ()) |
subtraction | (() - ()) |
multiplication | (() * ()) |
division | (() / ()) |
square root | ([sqrt v] of ()) |
modulus | ( ( ) mod ( ) ) |
Number Line
A number line can be used to represent integers and the values in between them. The following image depicts a number line:
Blocks
Many blocks take a number parameter or a small bubble that allows one to enter a number. The operators blocks in particular deal with numbers and many simple to advanced mathematical concepts. A variable can contain a numeric value and is often used as value-storing for varying purposes in a project.
Project Identification
Every project has an ID number found in the URL specific to that project. It is used to single out which project is which in the Scratch server.