The Python Programming LanguageΒΆ
Python is an example of a high-level language; other high-level languages you might have heard of are C++, PHP, Pascal, C#, and Java.
low-level languages: sometimes referred to as machine languages or assembly languages.
Computers can only execute programs written in low-level languages.
Programs written in a high-level language have to be translated into something more suitable before they can run.
- High-level languages advantages:
- much easier to program
- less time to write,
- they are shorter and easier to read, and
- they are more likely to be correct.
- they are portable, meaning that they can run on different kinds of computers with few or no modifications.
The engine that translates and runs Python is called the Python Interpreter:
There are two ways to use it: immediate mode and script mode.
In immediate mode, you type Python expressions into the Python Interpreter window, and the interpreter immediately shows the result:
$ python3
Python 3.2 (r32:88445, Mar 25 2011, 19:28:28)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 2 + 3
5
>>>
- The
>>>
is called the Python prompt. The interpreter uses the prompt to indicate that it is ready for instructions. - Alternatively, you can write a program in a file and use the interpreter to execute the contents of the file. Such a file is called a script.