Skip to main content

Section 1.4 The Python Programming Language

The programming language you will be learning is Python. Python is an example of a high-level language; other high-level languages you might have heard of are C++, PHP, and Java.
As you might infer from the name high-level language, there are also low-level languages, sometimes referred to as machine languages or assembly languages. Low-level languages can be “understood” directly by the computer’s CPU (Central Processing Unit). They aren’t, however, suitable for learning as your first programming language.
Programs written in a high-level language take less time to write, they are shorter and easier to read, and they are more likely to be correct. In order for a computer to run programs written in a high-level language, a special program called a compiler (for some languages) or an interpreter (for other languages, including Python) translates the high-level language into a low-level language that the computer can execute.
Another difference between high-level and low-level languages is that high-level languages are portable, meaning that they can run on different kinds of computers with few or no modifications. Low-level programs can run on only one kind of computer and have to be rewritten to run on another.
Due to these advantages, almost all programs are written in high-level languages. Low-level languages are used only for a few specialized applications.
There are two ways to use Python: shell mode and program mode. In shell mode, you type Python expressions into the Python shell, and the interpreter immediately shows the result.
In program mode, you write an entire program by placing lines of Python instructions in a file and then use the interpreter to execute the contents of the file as a whole. Such a file is often referred to as source code.
While it’s possible to run Python from the command prompt in Windows or the Terminal program in MacOS, there are easier ways to develop Python programs. In this book, you can write programs directly in the browser, or you can use an Integrated Development Environment to write your programs. The next two sections will examine these options in more detail.
Check your understanding

Checkpoint 1.4.1.

    Source code is another name for:
  • the instructions in a program, stored in a file.
  • The file that contains the instructions written in the high level language is called the source code file.
  • the language that you are programming in (e.g., Python).
  • This language is simply called the programming language, or simply the language.
  • the environment/tool in which you are programming.
  • The environment may be called the IDE, or integrated development environment, though not always.
  • the number (or "code") that you must input at the top of each program to tell the computer how to execute your program.
  • There is no such number that you must type in at the start of your program.

Checkpoint 1.4.2.

    What is the difference between a high-level programming language and a low-level programming language?
  • It is high-level if you are standing and low-level if you are sitting.
  • In this case high and low have nothing to do with altitude.
  • It is high-level if you are programming for a computer and low-level if you are programming for a phone or mobile device.
  • High and low have nothing to do with the type of device you are programming for. Instead, look at what it takes to run the program written in the language.
  • It is high-level if the program must be processed before it can run, and low-level if the computer can execute it without additional processing.
  • Python is a high level language but must be interpreted into machine code (binary) before it can be executed.
  • It is high-level if it easy to program in and is very short; it is low-level if it is really hard to program in and the programs are really long.
  • While it is true that it is generally easier to program in a high-level language and programs written in a high-level language are usually shorter, this is not always the case.