Computer programs mostly deal with data, electronic data. In this section we're going to look at what data are and how we store and manipulate data.
Computer programs do three basic things from our perspective.
- They get data into the program
- They process the data
- They output the data
Let's first look inside the computer at RAM. RAM stands for R**andom **A**ccess **M**emory. This means that the computer can get something in **RAM from anywhere very quickly. RAM is where the computer stores its data, including the operating system and the programs themselves. How do we imagine RAM? Here's one favorite way:
RAM is one long linear chain of bits. And a bit is a very simple thing, it's just a 0 or a 1. Think of each mark on the tape measure as a single bit. Data is just a collection of bits in a known spot. Say, starting at 5" on the tape measure and going for 10 marks.
What's a Variable¶
Computer programs need a way to find and use the data that they need. Data within a program are stored in variables. Physically as it were, a variable is a spot in RAM that has been given a name.
1 2 3
We start with the word
Then we have the name of the variable, in this case,
And, finally, we have a semicolon
;, which is required by course standards.
However, at this point, the variable doesn't have any value in it. Here's the variable declaration over again with a small addition.
1 2 3 4 5
We've added the
count = 1(variable name, a space, an assignment operator, a space, and the number 1).
This line puts the value 1 into the variable
count. (Technically, it puts a reference to the number 1 into it.)
1 2 3
Hands on work¶
Here's the final frame from the animated demo:¶