IF WE TALK ABOUT VARIABLES FIRST WE EMERGE THE PROBLEM IS "WHAT IS A VARIABLE",
Actually Variables are used to store information to be referenced and manipulated and to pass information around in a computer program. They also provide a way of labeling data with a descriptive name, so our programs can be understood more clearly by the reader and ourselves. It is helpful to think of variables as containers that hold information. Their sole purpose is to label and store data in memory. This data can then be used throughout your program.
so now i'am going to focus about main usages in variables there are ,
- To store information
- To manipulate data
- To pass information around in the program,
we can easily understand these ,using some prefer language, so i 'am going use python and scratch languages to describe usages of variables .
To store information
we can simply store data using variables giving the variable name to the left side and locate that store value or name to the right side like below.
Many variables store numbers and strings, like the ones above. Variables can also store other types of data, like lists, dictionaries, and Boolean values (true/false).
To manipulate data
Data manipulation is the process of changing data to make it easier to read or be more organized, Computers may also use data manipulation to display information to users in a more meaningful way, based on code in a software program, web page, or data formatting defined by a user.
as an example,
if you look at the first image of the scratch scenario it shows the score as zero because cat and mouse have some distance, so they are not touching each other though if you look at the second image of the scratch scenario it's showing score is "10" now the reason is whenever the cat is touching mouse score will change by "10", so you can easily understand how variables manipulate data
To pass information around the program
You can choose among three ways of passing data between programs: By reference, By content, or By value. By reference. The subprogram refers to and processes the data items in the storage of the calling program rather than working on a copy of the data
now the position of the mouse was communicated to the cat using variables, so variables can be used to communicate also...