LearnWave
Learn it. Master it.

Getting Started with Python

Meet Python

Run a statement in interactive mode and a program in script mode.

A program is an ordered set of instructions for the computer; a programming language is the language we write them in. Python is a high-level language, so its source code must be translated into machine language before it runs.

Python uses an interpreter. It translates and runs the program one statement at a time, and stops at the first error it finds. (A compiler, by contrast, translates the whole program first, and then it runs.)

Python's features:

  • It is free and open source.
  • It is interpreted.
  • It is easy to read, with simple, English-like statements.
  • It is case-sensitive: NUMBER, Number and number are three different names.
  • It is portable: the same program runs on Windows, Linux and macOS.
  • It has a rich library of ready-made code.
  • It uses indentation (spaces at the start of a line) to group statements into blocks.

There are two ways to work with Python:

  • Interactive mode: the Python shell shows the prompt >>>. Type a statement and press Enter, and it runs at once. This is handy for trying things out, but the statements cannot be saved.
  • Script mode: write the whole program in a file with the extension .py, save it, and then run it. In IDLE, choose Run → Run Module; the output appears in the shell. Use script mode for programs you want to keep.

Keywords are reserved words with special meanings in Python, such as False, None, True, and, if, else, while, for, def, return and import. They must be written exactly as given (Python is case-sensitive), and they cannot be used as names for anything else.

Interactive to try, script to keep.

Practise this lesson

Questions that get harder as you improve, a Tutor that helps without giving the answer away, and progress you can see. Free for every learner.

No account, no email address. Opens the real product.