CIS 2020 · Python for Everyone · Module 1 · Study guide

Module 1 review: sections 1.1 to 1.5

This covers the first five sections of Chapter 1, from what a program is to reading your first Python file line by line. It is short on purpose. If something here is new to you, go back to that section in the book before the quiz.

1.1 Computer programs

A computer does nothing on its own. A program is what puts it to work.

A program is a list of very simple instructions, together with the data those instructions act on. The computer follows the list exactly and very quickly. The same machine can play music, show a web page, or add up a column of numbers, because each of those jobs is a different program loaded into the same hardware.

Three words the quiz expects you to keep straight:

1.2 The anatomy of a computer

You do not need to be an engineer, but you should know the main parts and what each one is for.

To run a program, the computer first copies it from secondary storage into memory, and then the CPU works through it step by step.

The main parts of a computer A central bus connects the CPU and memory above it to secondary storage and the input and output devices below it. A program is copied from storage into memory, and then the CPU runs it. BUS (carries data between the parts) CPU runs one instruction at a time Memory (RAM) fast, volatile, holds the running program Secondary storage slower, keeps files without power Input and output keyboard, screen, network

1.3 The Python programming language

Where Python came from, and what "high level" means.

Python was written by Guido van Rossum and first released in 1991. The name comes from the British comedy group Monty Python, not the snake.

Python is a high level language. You write instructions that read a little like English and ordinary math, and a separate program called the interpreter turns them into the tiny steps the CPU understands. You never have to write CPU instructions yourself.

Python is clean and quick to read, which is why it is a common first language. It is not a teaching toy. It is used every day for data analysis, science, web servers, and automation. In this course we use Python 3.

1.4 Becoming familiar with your programming environment

Where your code lives and how you run it.

You write a Python program as plain text in an editor and save it in a file whose name ends in .py. The text you write is called the source code.

Most people work in an IDE, an integrated development environment, which puts the editor, a way to run the program, and tools for finding mistakes in one window. When your program produces text, it appears in a panel called the console or terminal.

Two habits the book pushes from the first day: back up your work often, and keep backup copies of earlier versions. A lost file is a lost afternoon.

1.5 Analyzing your first program

The traditional first program prints one line of text. Every word of it is worth naming.

print("Hello, World!")

A few rules that show up on the quiz:

Quick check

If you remember only these

  • Hardware is the machine, software is the programs, programming is writing them.
  • The CPU runs instructions one at a time. Memory (RAM) is fast and volatile. Secondary storage is slower and keeps data with the power off.
  • Python: Guido van Rossum, 1991, named after Monty Python. It is a high level language run by an interpreter.
  • Source code lives in a .py file. Output appears in the console.
  • print is a function. A string is text in quotes. The value you pass to a function is an argument.
  • Code runs top to bottom, one statement per line. A syntax error stops the program from running.