- 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 #) block, which identifies the placement of a costume in a sprite.
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|
(() + ())
(() - ())
(() * ())
(() / ())
|square root|| |
([sqrt v] of ())
A number line can be used to represent integers and the values in between them. The following image depicts a number line:
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.