Python Interpreter


We can start the Python interpreter from the command line.

Change to the directory where the interpreter lives, or add
the directory to your path. Then type

python


On UNIX, Python typically lives in /usr/local/bin; on Windows, Python probably lives in c:\python20.
On Windows, you can also bring the interpreter up from Start Programs Python 2.0 Python (command line).


Once we start the interpreter, Python displays something like this:

Python 2.0 (#8, Oct 1 2011, 17:27:58) [MSC 32 bit (Intel)] on win32
Type “copyright”, “credits” or “license” for more information.
>>> 

The interpreter displays the >>> prompt to show that it’s ready for you to type in
some Python. And so, in the grand tradition of programming books everywhere, we
proceed to the “Hello world” example:

>>> print “Hello world!”

Hello world!

To exit the interpreter, type the end-of-file character (Ctrl-Z on Windows, or Ctrl-D on Linux) and press Enter.



No comments:

Post a Comment