The text begins with the very basic idea that computers are composed of two very different kinds of components, hardware and software. We classify all physical components of a system as hardware. Hardware alone is not enough to make a computer do anything useful. We also need software, which can be classified many different ways as we will see in this chapter.
The text divides hardware into five types. Most hardware that we associate with a computer will fit into these categories. A computer may have cables, ports, and adapters as well as other components, but these five types cover the essentials.
Turning to software, the text briefly discusses two types.
Computers store and handle instructions and data as digital information. Everything is stored and used as some combination of 1s and 0s, which is often compared to a set of switches that are either turned on (1) or turned off (0). The number system that people normally use is the decimal system, based on ten digits (0 through 9). The numbering system used in computers is typically the binary system, based on two digits (0 and 1). In a binary system, we can refer to a cell in memory as holding one binary digit (abbreviated as one bit) that is either a 0 or a 1.
If we only had two digits, we could only represent two things, but we can have collections of digits that can represent an unlimited number of things. In the case of computers, we often see systems that use clusters of 8 bits, which are called bytes. Each byte will represent one character or keypress in some code system, such as the American Standard Code for Information Interchange, ASCII. Files written in ASCII (pronounced like ask-key) may be written in just the original 128 characters defined by seven bits of a byte, or in the extended ASCII code that uses eight bits. See the table of defined characters on this web page. ASCII was created by ANSI, the American National Standards Institute. A more modern code system is Unicode. It was created in the late 1980s and early 1990s by a consortium of vendors to represent more characters (16 bits per symbol); later it was expanded to use four bytes for some characters, so it has the capacity to store the characters for all current languages and some dead languages. Unicode includes extended ASCII as the first 256 characters in its system.
So, that's a bit of background about bits and bytes and code systems. We came here to talk about programs, so how does a CPU use a program? As noted above, it is told to run a program. See the diagram on page 15:
The text tells us that programs are typically machine language, but they are no longer written that way. They can be written in assembly language, which is one level removed from the actual language of the CPU. Even though this was once a wonderful thing, to be able to write in the symbolic code of an assembler, it is still not clear what such code really means unless you are an expert in it, so rewriting or debugging a program written in assembly language is not a good way to learn programming.
This takes us to high level languages, which more closely resemble human languages. A list of several high level languages appears on page 17. Each is different from all the others in some way, but one thing most of them have in common is that they are hard to learn. This takes us to Python, which is a language that was meant to be easy to learn and easy to use. If you have some trouble with it this term, think about something Winston Churchill said about democracy, and apply it to Python. He said that democracy is a very poor form of government, but all the others are so much worse.
All high level languages contain similar components. Key words are typically commands, such as those in the list on page 17. Those that are not commands are used to tell the CPU how to follow a command.
High level languages also contain operators, which come several types, as show in the discussion of Python operators on this web site. Some operators are words, and some are symbols. We won't go deeply into that in this lesson.
The third thing all languages have is syntax, which would mean grammar and punctuation if we were talking about a human language. For a programming language, it means something very similar. Programs have to be written rather precisely or they will not be understood by the computer trying to run them.
On page 18, the text informs us that some languages are compiled and others are interpreted. In both cases, a program is written in what we will call source code, the high level language, often saved as a plain text file with a funny extension. Programs can also be called scripts, as most programs saved in text files are called. The funny extension for Python programs is .py
Python is an interpreted language. Computers in our classroom should have a Python interpreter installed on them for us already. Your own computer may need to you to install it before you can run a Python program. Starting the Python interpreter will open a command line shell, which will allow you to run programs you have saved, or issue commands in interactive mode. It will look a lot like this (captured from my computer):
Note that I entered the sample command shown on page 21 twice. The first time, I entered it correctly. The second time I entered it with a syntax error: I did not type the closing parenthesis before I pressed the enter key. The Python interpreter gave me a new prompt, an ellipsis, that meant it was waiting for me to finish the command. I typed the closing parenthesis, pressed enter, and the line of code ran properly.
The text tells us to press control-z to exit the Python interpreter, but this does not work on my computer. Closing the window in which the interpreter is running does work. On page 23, we learn that we can call the Python interpreter from a command line, and pass the name of a saved file to it at the same time. The text refers to this as starting the interpreter in script mode, handing it a script directly.
Instead of running an interpreter session directly, you can probably start the IDLE shell, and integrated development view of Python. It was installed along with Python manuals and the interpreter when I downloaded my copy of Python.