Installing and Using the Software


While this is not a programming course, you will do a fair bit of coding, far more than in CSCI2243. We will use the Python programming language.   From Python itself, I want you to be able to write functions, use simple looping and branching, and manipulate one-dimensional lists.  (No need to worry about tuples, dictionaries, or object-oriented stuff.) 


Software Installation

The following installation procedures worked for me when I tried them on a number of machines, including an ancient Windows laptop, but some students invariably have issues with this, usually because their computers are configured somewhat differently from the norm.  Please try to do this installation as early as you can, and let me know as soon as possible if you encounter any problems.

Python

We use Python 2.7 in this course. Python has been gradually moving away from Python 2, and in a few years' time, Python 3 will have completely supplanted it.  Unfortunately, the two languages are not compatible,So even if you already have Python 3 installed on your computer, you sill still need to have Python 2.7 for this course.  If you took CSCI1101 in Python, and haven't switched computers, you  already have it.  If not, go to

https://www.python.org/downloads/release/python-2714/

 download the installer for Python 2.7.14 for your operating system and launch the installation.  If you have an older computer, you may want to download the 32-bit version of the installer, rather than the 64-bit version.

Advice for Windows users: If you have an older Windows laptop, it may help to drop back to earlier releases of Python 2.7.

Advice for Mac users:  If you have a Mac that shipped with a pre-installed version of Python, I recommend that you do this installation anyway---it does not take up a lot of extra space, and this seems to make the next step go more smoothly.)


matplotlib


We will use Python in conjunction with the plotting library matplotlib. 
On Mac OSX:
Open the Terminal application and type

pip install -U matplotlib
On Windows:

Open the Command Prompt application and type

python -m pip install -U pip
python -m pip install -U matplotlib

If you get a message that the command 'python' is not recognized you either need to navigate to where the Python executable python.exe is installed (usually c:\Python27) to type the commands, or add the path c:\Python27\python.exe to the system path variable.

Test the Installation

Start up IDLE.  Type these three lines at the successive prompts.

from pylab import *
plot(range(5),sqrt(range(5)))
show()


It may take a moment for the prompt to return after the first line, but there should be no error messages.  The second line should result in a message like

[<matplotlib.lines.Line2D object at 0x96a24d0>]

Finally, the third line should display a very crude graph of the square root function.

Using matplotlib

There are several different ways to use matplotlib. The procedure that I follow is not always the recommended one, because of the risk of conflicting names from different packages, but I find that it works reasonably well and makes most things simpler. 

When you installed matplotlib, the numerical Python library NumPy was also installed. Typing

from pylab import *

imports  core capabilities of NumPy along with the plotting libraries for matplotlib.  The stuff from NumPy replaces much of the math library from standard Python.  For example, you might note that in the code fragment above, we used the function sqrt without the usual invocation of import math and a call to math.sqrt.  Pay particular attention to what happens with random number generation, which we do a lot of in this course.  The pylab import provides functions random and randint, just as in the standard package random. However, a call to randint(i,j) returns a random integer in the set {i,..,j-1}, and not in {i,...,j} as in the standard Python package.

During the first week of class I will give a detailed demo of the software.  For reference, here is the documentation for the plotting commands in matplotlib, and here is documentation for NumPy.