Intro to
Programming
with Python

Fall 2011
course
navigation

nov 29

I've put more here that we can do today. We'll pick and choose and/or continue Thursday.

1. Final project questions? Presentations one week from today; due a week from Friday. Discuss status.
Project rubrik: - idea / difficulty / planning - mastery of course material - follow through / finished & runs without error - docs / tests / sample output / easy to see how it works
2. Course evaluations.

3. Python examples :

3a. scientific python : discuss numpy, matplotlib, etc; look at some examples.
Fast manipulations of big collections of numbers, including plots, transforms, programming.
Similar tools: MatLab, IDL, GDL
Numpy has several classes for collections of numbers:
$ python >>> from pylab import * # all matplotlib.pyplot & numpy names # plot of sin(x)/x >>> dx = 0.01 >>> x = arange(dx, 4*pi, dx) # array range >>> y = sin(x)/x # element by element >>> plot(x, y) # statistics >>> mean(y) 0.11840453572377389 >>> std(y) # standard deviation 0.3278530674534389 # manipulating an array >>> x.ndim 1 >>> x.shape (1256,) >>> x[3:4] array([ 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1 ]) # a histogram >>> x = randn(10000) >>> hist(x, 100) # matrix work # *** note that numpy's, nm[i,j] is python's m[i][j] >>> m = matrix([[1,2,3], [1,0,1], [0,2,-1]]) >>> m matrix([[1, 2, 3], [1, 0, 1], [0, 2, -1]]) >>> m[0,:] matrix([[1, 2, 3]]) >>> m[: , 0] # remember that a[:] is all elements matrix([[1], [1], [0]]) >>> m * m # matrix multiplication matrix([[ 3, 8, 2], [ 1, 4, 2], [ 2, -2, 3]]) >>> m[0:2, 0:2] matrix([[1, 2], [1, 0]]) >>> inv(m) matrix([[-0.33333333, 1.33333333, 0.33333333], [ 0.16666667, -0.16666667, 0.33333333], [ 0.33333333, -0.33333333, -0.33333333]]) >>>
3b. Tron robots from last year's programming workshop
Browse through a bit of the code:
Run an example from notes on my laptop at /Users/mahoney/academics/term/2010-01-spring/programming_workshop/tron/
3c. a program from a previous student's plan: traveling salesman


4. Review: walk through everything we've done this semester.
http://cs.marlboro.edu/ courses/ fall2011/python/ notes/ nov_29
last modified Tuesday November 29 2011 10:08 am EST

attachments [paper clip]

     name last modified size
   3d.py Nov 28 2011 11:46 pm 406B [DIR]traveling_salesman/ Nov 28 2011 11:56 pm -