Minimal Python

If you are not learning Python, skip this section.

The simplest way to run Python is to run interactively. Before starting you should decide whether you want Python 2, which has a limited shelf life now, or Python 3, the new standard. We use Python 3.

To start Python 3 on our system, at the command line prompt in your terminal, type

/usr/local/bin/python3

(You can also simply type python3 on our system.) This command opens an interactive Python 3 session. Python prompts for commands using a triple chevron >>>. At the Python prompt, type print('Hello, world!') as in

>>> print('Hello, world!')

You should get a new line with Hello, world!. Note that Python strings must be set off by either single or double quotes.

To do something slightly more useful, you can use Python as a calculator. Say you wanted to know by what factor an investment would increase in value over 20 years at 4% annual compound interest. The answer is

print(1.04**20)

You should get 2.191123143033421 to far more significant figures than needed.

To exit from Python, type Crtl-d.