Monthly Archive: November 2009

Tavolo

2009

Tavolo is a tabletop application for conferences. This application was developed for the Microsoft Surface using the WPF Framework.

Read the rest of this entry »

Loading a file to a list

This week in tutorial we covered file input.

A specific example of how to take a command line argument, and input the file into a list is available here

November 23rd CT Hours Cancelled

CT Hours for Monday November 23rd will be cancelled. If you have any questions, please contact me at

Week of November 23rd, 2009

I will be out of town from Monday the 23nd until Wednesday the 25th. My tutorials will be covered by the other TAs as follows.

T01 – Tedd Hellmann
T03 – Kate Chatfield-Reed

I will be available by email most of this week, although at times, my responses will likely be delayed.

Grayscale Example

Another good example of how to work with images is available in this Grayscale image example.

One thing to note specifically in this example is the use of variables, and lack of “magic numbers”.

Assignment 3

Assignment 3 is due Friday, November 20th at Noon.

For this assignment you will likely find the following files useful:
ppm.py
DonaldDuck.ppm
Lion.ppm
HelloWorld.ppm
Parrot.ppm
Sky.ppm

Chris Luce has also created a sample program to get you started. This program requires ppm.py and DonaldDuck.ppm, and will display the DonaldDuck.ppm file.

2D Lists

This has been shamelessly borrowed from Chris Luce, as he showed them in one of my tutorials last week.

This example shows a Tic Tac Toe checker, to see if there is a win in a board, or if it’s a cats game.

This example uses a 2 dimensional list, which you may find helpful to understand for your assignment.

Scope of Variables

We covered a number of examples using scope. I have decided to post these examples so that they will hopefully help you all better understand scope.

scope 0
scope 1
scope 2
scope 3
scope 4
scope 5

Function Example: Assignment 2

A good example of how to use functions is a modified version of assignment 2, available here.

In this example, we created a few helper functions, like the ones below to convert values between cartesian values and screen coordinates

#convert an x value from cartesian coordinates to screen coordinates
def cartx(x):
	x = scale * x
	x = xcenter + x
	return x

#convert an x value from cartesian coordinates to screen coordinates
def carty(y):
	y = scale * y
	y = ycenter - y
	return y

The core of the program, that is, the drawing of the curve was also done using functions, as seen here

#Draw the curve defined by a,b,c and d from a beginning cartesian value to an end cartesian value
#approximating by delta cartesian units
def draw(a,b,c,d,begin,end,delta):
	x = begin
	while x < end:
		y = formula(a,b,c,d,x)
		y2 = formula(a,b,c,d,x+delta)

		print "line",cartx(x),carty(y),cartx(x+delta),carty(y2)

		x = x + delta
	sys.stdout.flush()