PRB - Variable/Identifier (Lesson)
Variable/Identifier
Variables
Let's look at another analogy, another comparison between two objects and actions.
The homework in the teacher's collection box or a piece of mail in a mailbox. Are these similar?
Of course.
The homework and the mail are data
the collection box and the mailbox is where the data is held.
A word variable holds data in computer science and math.
Think of the holding place for each of the following and a place that would not be a good holding place.
More Real Life Examples
So, let's begin by finding out what we do on a daily basis like a computer and then, let's learn to program.
Suppose you want to mail a letter. To mail a letter you put the letter in a mailbox. The mailbox is the receptacle of the letter, the holder of the letter.
Suppose you want to send an email. You have the email written and the email is stored on the email server until you push send. Then it is routed to the recipient email server where it is stored and your copy is now in a sent folder for later lookup. The holder of the email is a server on both ends.
Returning to alphabetizing, depositing homework in a teacher's box, and training a dog to sit - we saw that data was stored:
- as an object
- physical items of papers to alphabetize
- homework paper
- in memory
- order of letters in the alphabet, A is first, B comes next, etc.
- how to execute alphabetizing papers, organization of moving papers and getting the letters of last name, first name in order
- how to turn in the homework paper
- the word 'sit'
- what to do when the word sit is recognized, the motions to make sit happen
Note the items in memory that we did not think: the steps or the instructions to make the output happen. In our memory, we have learned what to do to alphabetize, put numbers in order, turn in homework, pour a glass of milk, and if we train a dog, we have learned the steps to do so. As we know, the order of the steps is important. If we pour the milk prior to getting a glass to pour the milk into, the milk will spill. Thus - stored in memory - is a series of steps to carry out the task that is recognized by the request to do something.
So, how does a computer hold data?
A computer holds data by using an identifier or a variable that the computer and the programmer understand.
The variable/identifier is of a particular type. In language, there are also different data identifiers: words, numbers, symbols, etc. With our real-life examples, we can identify these types of data that we have discussed.
- In a math data type: numerical data
- In an object data type: descriptive data, like a dog
- In a word data type: textual data
Each of these different types of data structures are named by the programmer for use in their program. These data structures store the data either in memory or on a storage medium until the information is needed.
IMAGE CREATED BY GAVS AND USED ACCORDING TO TERMS OF USE.