First Summer 2010

Grades Office Hours Students Books24x7

Thu Jun 10, 2010
Linger provided this document last semester: Python review.

Notes for today will change tonight to include what we did in class (lecture).

Tomorrow we finish reviewing the problems from the 5th Friday Exam.

Thu Jun 10, 2010
Lab notes with answers from today's lab.

Linger's lab notes from yesterday and the day before.

Wed Jun 09, 2010
Problem suggested by Asaf: here.

The code we wrote in class today: here.

Tue Jun 08, 2010
Here's the Watch class developed in class today.

In lab today:

I'll be coming to lab around 3:55pm to return exams.

Turn in the code for: car, Point, Line, and Triangle (in OnCourse).

Lecture notes from yesterday: here (as developed in class).

Lecture notes for today updated (see Class Notes page.

Fri Jun 04, 2010
Grades including today's Fourth Friday Exam have been posted.

Individual reports coming to you by e-mail later tonight.

Meanwhile reading assignment for Monday is Dawson -- chapter 8 (classes and objects).

Plan for next week:

Read chapter 8 from Dawson for Monday.

Thu Jun 03, 2010
For today's lab please work alone or in a pair.

The task is to find the answer to all the questions listed in Thu 06/03 notes.

I'll post the solutions tonight.

Wed Jun 02, 2010
Yesterday's lab notes by Linger: here.

Answers to the lab questions of yesterday.

Another Python implementation of the tower puzzle and its output.

Tue Jun 01, 2010
Link used by Linger in lab. Another site: here.

What we wrote in lecture can be found here.

Notes for today (lecture and lab) posted on Class Notes.

FYI -- problem administered to a makeup test earlier today:

Write a program that collects names and ages of some people:
	type> Jennifer 16
	type> David 18
and so on. When the user is out of data the user types 'bye'.

At this point the program prints back all the names in the ascending order of the numbers.

Where two names have the same number the names should be printed in lexicografic order (e.g., Jane goes in front of Jennifer which goes in front of Jenny).

In your printout you print back those same lines (e.g., "Jennifer 16", "Dave 18") just sorted as described.

Strings have a split method that you might need to work with: "this is it".split() returns ['this', 'is', 'it'].

Dictionaries have a keys method: d.keys() returns a list of the keys in dictionary d.

Other dictionary methods: d.values(), d.items()

Thu May 27, 2010
Teams for today's lab exercise:

Josh - Joe


Sean - Michael

Ellen - Andy

Jenny - Kentaro

Anwar - Bryan

For the lab split the problems in 2 and 3 and explain them to each other.

A short grading summary about your partner and yourself is to be uploaded to OnCourse.

No class Monday (Memorial Day) May 31, 2010.

Chapter 6 is your reading assignment for Tuesday, June 1, 2010.

Here's something to think about for then:

  1. Bring the kids down
  2. Bring the queen down
  3. Bring the kids down (again!)
Can this be a valid (easy to remember too!) solution to the prisoners' problem?

Now here are the solutions for the:

We'll discuss them all in class today.

In lab you'll again group in pairs and present solutions to each other.

The third Friday Exam is tomorrow (three problems assigned randomly from the five above).

Wed May 26, 2010
Here are the boards from today:

Click on any of the three boards to blow it up.

What we developed at the end of the lecture today on computer:

Word Profile


b 1
a 3
n 2

for every letter in the word:
  if letter seen for the first time:
    count and report occurrences
    mark this letter as "already seen"
    stay quiet

seen = []
word = raw_input("Type word: ")
for letter in word:
    if letter in seen:
        print "I already told you about", letter
        seen.append(letter) # seen = seen + [letter]
        print letter, "appears", word.count(letter), "times"

Here's another way that uses the new tool (dictionaries): 

set up an empty dictionary
for every letter in word:
  if letter not a key in dictionary:
    add entry with a value of 1 to dictionary
    add one to the value associated with this key in the dictionary
Here's what we did to get a feel for how dictionaries work:

IDLE 2.6.2      
>>> a = "banana"
>>> a.count('b')
>>> a.count('a')
>>> ================================ RESTART ================================
Type word: banana
b appears 1 times
a appears 3 times
n appears 2 times
a appears 3 times
n appears 2 times
a appears 3 times
>>> ================================ RESTART ================================
Type word: banana
b appears 1 times

Traceback (most recent call last):
  File "C:/Users/dgerman/Desktop/", line 4, in <module>
    if letter in seen:
TypeError: argument of type 'NoneType' is not iterable
>>> ================================ RESTART ================================
Type word: banana
b appears 1 times
a appears 3 times
n appears 2 times
>>> ================================ RESTART ================================
Type word: banana
b appears 1 times
a appears 3 times
n appears 2 times
I already told you about a
I already told you about n
I already told you about a
>>> a = []
>>> d = {}
>>> a.append(1)
>>> a.append(9)
>>> a.append(2)
>>> a.append(7)
>>> a
[1, 9, 2, 7]
>>> a[1]
>>> a = ['five', 'nine', 'three', 'one', 'five']
>>> a
['five', 'nine', 'three', 'one', 'five']
>>> a[1]
>>> d = {'dgerman':'sp00n', 'lbird':'dribl'}
>>> d
{'lbird': 'dribl', 'dgerman': 'sp00n'}
>>> d['dgerman']
>>> d['mjordan']

Traceback (most recent call last):
  File "<pyshell#19>", line 1, in <module>
KeyError: 'mjordan'
>>> d['mjordan'] = 'se7f6bu$2'
>>> d
{'lbird': 'dribl', 'mjordan': 'se7f6bu$2', 'dgerman': 'sp00n'}
>>> d['mjordan']
>>> d['mjordan'] = 'jumpman'
>>> d
{'lbird': 'dribl', 'mjordan': 'jumpman', 'dgerman': 'sp00n'}
>>> d.has_key('mjordan')
>>> d.has_key('cbarkley')
This includes tests on lists for getting the problem done without dictionaries (only lists).

Notes for today have been posted.

I won't be able to come to lab until 3:50pm or so.

There's a quiz you need to go through in lab (see lecture and lab notes for today).

Tue May 25, 2010
Today's notes, reading assignment for Wednesday, posted.

Here are Linger's notes from today's lab as well.

Mon May 24, 2010
You can check grades here.

You need to authenticate with your IUB network ID.

Select A201-0524 as the class (0524 is made up, it's today's date.)

I'm going to polish the format a bit tonight.

Fri May 21, 2010
Your problem distribution for the second Friday exam:

Ng, Andy Ting Chung     [8, 2, 1, 7]    present

Jindal, Amit            [5, 7, 2, 3]    present

Doner, Craig Michael    [1, 8, 4, 3]    present

Peck, Michael Thomas    [6, 4, 5, 7]    ?

Qiang, Yuhong           [3, 2, 5, 8]    ?

Kolski , Bryan Todd     [3, 1, 5, 6]    present

Alsanea, Anwar          [2, 6, 4, 5]    present

Sills, Sean Michael     [8, 2, 1, 3]    present

Sakuwa, Kentaro         [5, 3, 6, 1]    present

Lipson, Jennie          [8, 2, 3, 1]    present

Knipstine, Eric Daniel  [7, 6, 1, 8]    present

Gamble, Joshua Eric     [3, 1, 2, 8]    present

Migliano, Joseph Daniel [7, 2, 6, 3]    present

Sakamoto, Takuro        [2, 4, 8, 6]    ?

Cogswell, Stephen       [1, 4, 3, 5]    ?

Jeong, Gyeonghun        [6, 3, 5, 7]    present

1:14 PM 5/21/2010---------------------------------
Problem no.     1  2  3  4  5  6  7  8    Total
Times chosen:   9  9 11  5  8  8  6  8      64

Fri May 21, 2010
Here's the code I will run in class today:
import random 
d = {}
for name in [ "Alsanea, Anwar"  , "Cogswell, Stephen Michael", "Doner, Craig Michael"  , "Gamble, Joshua Eric" , \
              "Jeong, Gyeonghun", "Jindal, Amit"             , "Knipstine, Eric Daniel", "Kolski , Bryan Todd" ,  \
              "Lipson, Jennie"  , "Migliano, Joseph Daniel"  , "Ng, Andy Ting Chung"   , "Peck, Michael Thomas",   \
              "Qiang, Yuhong"   , "Sakamoto, Takuro"         , "Sills, Sean Michael"   , "Sakuwa, Kentaro"]:
    d[name] = []
    while len(d[name]) < 4:
        while True:
            pick = random.randrange(8) + 1
            if pick in d[name]:

for name in d.keys():
    print name
    print "\t", d[name]

Thu May 20, 2010
Teams for the lab today:

Eric - Sean
Michael- Jennie
Josh- Joe
Gyeonghu- Takuro
Marwa- Amit
Ellen- Anwar
Bryan- Craig
Each team splits the problems like last time.

Explain the problems to your teammate, write a report about his/her weaknesses (if any) and post it.

Include a few words about yourself in the report (what are your weaknesses, as you see them, if any?).

Notes as written in class today.

Don't forget we have additional notes posted on Class Notes.

Wed May 19, 2010
Please work on Problems 4 and 6 in the first hour (2:40pm-3:40pm).

You can only talk to your neighbor and/or Linger.

An old example of decision process.

The notes as we will write them in class today.

The quiz distributed in class today.

Tue May 18, 2010
To download Python: go to this website.

To read Python documentation: here (on the same website)

There is a tutorial on the website: here.

Mon May 17, 2010
Notes as we wrote them today in class.

Thu May 13, 2010
Tomorrow we will have the first Friday exam.

In lab today you will work in pairs and study for the exam.

Solutions to the 9 (nine) problems on the exam have been posted under 05/13 notes.

Tue May 11, 2010
Program developed by Linger in the first part of the lab:

name = raw_input("What's your name? ")
print "Hi, " + name +", how old are you? ", 
age = raw_input()
age = int(age)
age = age + 1
age = str(age)
print "Well, " + name + ", you will be " + age + " next year!"
First Summer Session starts. A201/A597 starts today in LH102 at 1:10pm.

Link to Books24x7. Authenticate, then search for:

The text is Python for the absolute beginner by Michael Dawson.

Here's a script to be used in class (lecture mostly, but also labs).

Here's another script you can use to make appointments for office hours.

Updated by Adrian German for A201/A597