This section provides information regarding how to run python and use a command prompt on your computer. We've done our best to provide information for all major operating systems (although it's easier on some systems than on others).

On Mac OS X:

The Terminal window is like a text-based version of your computer. From here, many common actions, like creating or navigating folders and launching applications, can be performed via the command line. On Mac and Linux, the Terminal application can be accessed from the Applications folder or using a quick-search function. Look for this image:

On Windows

Windows allows you to perform many common actions, like creating or navigating folders and launching applications, from what is called the CMD command prompt. Do a search for for cmd.exe on your computer. Note: Python may not be set up properly on windows. If you are unable to get python to work from the command line (as explained below) here is a link that will help you get things set up.

Running Python

The next step is to open the Python "interpreter". On the command line type python3 and hit the return key. The "3" indicates the version of python we will be using in this lab. You should see something similar to the following:


Alonzos-MacBook:~ alonzo$ python3
Python 3.4.0 (v3.4.0:04f714765c13, Month DD YYYY, HH:MM:SS) 
[GCC X.X.X] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
        


Note: The version of Python being used in this lab is Python 3.4. On your own computer, you may not have version 3.4. Try loading just python if you don't have version 3. There are a few differences with Python 2.x, but everything in this lab should work well in both versions.


The >>> indicates where to enter python code. After typing a line of code, hitting the Enter key will tell the python interpreter to run the instruction. Try typing the following into the interpreter:


>>> 3 + 5
8
        

If the text cursor is on a line beginning with >>>, the command line window has an active python interpreter open. From here you won't be able to run any other command. To leave the python interpreter type the exit command exit() and hit the Enter key.


>>> exit()
Alonzos-MacBook:~ alonzo$
        

Any functions or variables created in the python interpreter are erased when the exit() command is run.