Python “hello, world!” (at the interpreter)

Working with Abjad means programming in Python. Let’s start with Python’s interactive interpreter.

Starting the interpreter

Open the terminal and type python to start the interpreter:

$ python

Python responds with version information and a prompt:

Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

The purpose of the interpreter is to let you try out code one line at a time.

Entering commands

Type the following at the interpreter’s prompt:

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

Python responds by printing hello, world! to the terminal.

Stopping the interpreter

Type quit(). Or type the two-key combination ctrl+D:

>>> quit()

The interpreter stops and returns you to the terminal.

The Python interpreter is a good way to do relatively small things quickly.

But as your projects become more complex you will want to organize the code you write in files.

This is the topic of the next tutorial.