Variables are used in nearly every single computer program. They are an essential concept and can be used and manipulated using many different techniques. The following spider diagram summarises the key computing concepts linked to the use of variables in procedural programming:
Depending on where in your code you declare a variable will have an impact on its scope.
A variable which is declared within a subprogram (e.g. procedure or function) is only available within this subprogram. It is a local variable.
A variable which is declared outside any subprograms becomes accessible to code written anywhere in the program. It is a global variable.
score = 0
numberOfLives = 3
e.g. in Python using functions such as int(), str(), float().
score += 1
timer -= 1
Some more complex data structures such as lists and arrays enable you to store multiple values in a single variable.