There are (at least) two kinds of knowledge: (1) declarative knowledge, which are statements of fact; and (2) imperative knowledge, which are recipes or “how-to”s.
Programming is about writing recipes to generate statements of fact.
What is the square root of 16? (declarative knowledge)
Babylonian square root finding algorithm (imperative knowledge)
An algorithm is a (1) sequence of steps with (2) clearly defined control flow specifying when each step is executed and (3) a means of determining when to stop.
Computers, then, are machines that execute algorithms. Computers can perform billions of simple operations per section and store those results in memory.
At one point, computers were fixed-program computers; they had a fixed set of algorithms they could perform. However, there was a key insight: programs are no different from other kinds of data. That means we can store programs in memory, and operate on them (i.e. execute them) like another other piece of data. This insight led to the formation of stored-program computers.
Stored-program computers have a predefined set of primitive instructions. The set of primitive instructions include:
If these primitive instructions can execute any program a Turing machine can execute, that set of instructions is called Turing-complete.
First and foremost, a programming language is a language. Thus, we should examine aspects of languages.
Languages have primitive constructs. Languages also have syntax. When someone does not obey the syntax rules, they commit a syntax error, and these are common but easily caught.
Beyond syntax, however, languages have semantics: the meaning associated with a syntactically correct string of symbols.
A program is a sequence of definitions and commands. Definitions are evaluated while commands are executed.
Python is an interpreted language: a special program called an interpreter executes your programs.
Objects are representations of the world, but to build meaningful programs, we need to be able to manipulate these objects. That is the function of operators. In programming, we combine objects and operators to form expressions.