CIT 591 Previous Announcements
Fall 2009, David Matuszek

Somewhat relevant link: Book recommendation.

Date Announcements
December 12, 2009

I've been asked to post more examples of "good" (well-written) programs. Here they are:

December 8, 2009

Questionnaire results

  • Non-credit language courses
    • 10 uninterested, 4 interested if cheap/free, 7 interested.
    • Much more interest by my CIT597 students: 5 interested, 1 if cheap/free, 1 uninterested.
      • I think CIT591 students overestimate how much other languages, such as C++, are in the curriculum.
  • Starting with Python
    • Big win: 17 were in favor, 3 had mixed feelings, 3 didn't like
    • Biggest problem: Java was too rushed, transition was difficult.
      • I can abbreviate Python a bit, and I have some ideas about smoothing the transition.
  • Pair programming
    • 11 people didn't like it at all, 7 had mixed feelings, 5 liked it.
    • Biggest problem: Incompatible schedules, making it hard to work together.
    • Other problems: Skill levels too different, unhelpful partners.
  • Test Driven Development/Design
    • 11 people reallly liked it, another 8 liked it somewhat, 2 didn't like it.
    • Only 1 person admits to not trying it, but complaints from partners suggest there are more.
    • In some cases, writing the tests was too much of a hassle.
      • I need to give more instruction on testing difficult cases, e.g., methods involving randomness.
  • How to improve this course
    • Many suggestions to drop PowerPoint, teach Java like I taught Python.
      • Eclipse isn't as easy as IDLE for this; maybe if I move to a simpler IDE, like DrJava?
    • More individual assignments, especially when beginning Java.
    • Get to Java sooner, so students can get more familiar with it.
    • More of x, where x takes on a large number of different values.
December 7, 2009 It turns out that adding a KeyListener to a JPanel or a JFrame isn't enough; you also have to tell the JPanel or JFrame setFocusable(true). [Thanks, Vishal.]
December 4, 2009

I have been forgetting to post partner evaluation forms. My apologies. Remember, these are a required part of the course.

To keep from forgetting again, I have posted the evaluation form for the last assignment. Please fill out this form immediately after submitting the assignment.

December 3, 2009 Error: The instructions for the load(), save(), and saveAs() methods in the StudyList class are contradictory. They say to catch any IOException, but the method headers say that the exception should be passed on to the calling method.
Correction: The above-named methods should not catch exceptions. The method headers are correct.
December 1, 2009 An improved version of has been posted. This version treats a Save command as a Save As command if no file has previously been loaded, and fixes a (hopefully uncommon) bug.
November 20, 2009

Because so many people will be leaving early for Thanksgiving, I have tried to make it as painless as possible to skip the November 25 class, by making it clear that no new material would be covered. I've now decided that's just foolish.
No class November 25. No lab November 27.
Happy Thanksgiving!

October 29, 2009

Pizza party!

Thursday, November 19, 6 p.m.
Levine 307

Who is invited: All current and former MCIT students and faculty, and students taking MCIT classes. OK to bring a guest. An informal RSVP to would be appreciated.

November 12, 2009

I recommend going to this talk. --Dave

Cracking the Technical Interview:
Advice for CS students on interviewing for software engineer positions

Gayle Laakmann
4:30pm, Wednesday, November 18, 2009
Wu & Chen Auditorium

November 12, 2009 The Partner Evaluation form for 07 Fractions is now available. Please note that these forms are mandatory, even if you had no partner.

If you have not yet filled out partner evaluation forms for previous assignments, they are available on the Previous announcements page.
November 12, 2009 No office hours today. I am staying home with a cold and sore throat.
November 5, 2009 In your public int compareTo(Object o) method, it's easy enough to test whether o is a Fraction:
     if (o instanceof Fraction)...
However, there is no direct way to test whether o contains an integer. Here's a bit of hocus-pocus (which I will explain in the next lecture) that you can use:
     int n = (Integer)o;
This will either (1) put the appropriate integer value into variable n, or (2) throw a ClassCastException. Since your compareTo method is supposed to throw this exception if it gets the wrong kind of argument, this statement does almost exactly what you need.
November 3, 2009 Because Dr. Dietz is giving an exam on Thursday, the Fractions assignment will be due by midnight Friday.
November 1, 2009

The Partner Evaluation form for 06 Balanced Ternary is now available. Please note that these form are mandatory, even if you had no partner.

If you have not yet filled out partner evaluation forms for previous assignments, they are available on the Previous announcements page.
October 29, 2009 I've been forgetting to announce this Frowny face. Hope you can all come!

Pizza party!

Thursday, October 29, 6 p.m.
Levine 307

Who is invited: All current and former MCIT students and faculty, and students taking MCIT classes. OK to bring a guest.

October 28, 2009 Wednesday help sessions resume today, approximately 4:45, in Jaffe B17.
October 26, 2009
midterm exam   Average (mean) 63.60

  Median 60.0

   St. dev. 15.58

I have posted the exam and its answer key.
October 23, 2009 The due date for the Balanced Ternary Assignment is midnight Thursday, October 29.
October 22, 2009

If you are having trouble submitting a partner evaluation form, please wait a bit and try again. The server is hosted at my home, and we are having intermittent telephone problems that Verizon is not rushing to fix.
The three current forms are:

October 21, 2009

No lab this Friday (although it would be a good time for you and your partner to come in to work on the final Python assignment).

No help session today after class. Will resume next week.

October 19, 2009

Please submit this form:

October 16, 2009

I finally have the partner evaluation form program working again. Please fill in the following two forms:

I will post the evaluation form for the Small Town assignment after the final due date for it. Again, these evaluations are mandatory and completely confidential.

October 14, 2009 The due date for the Small Town Traffic assignment is extended to Midnight Sunday.
October 11, 2009 Addendum to the Small Town Traffic assignment.
October 11, 2009 If you are getting readability scores that are slightly different from mine for Kant's Critique of Practical Reason, but the scores on other files are the same, don't worry about it. There is a special case, "THE END", that we handled differently. You won't lose points for this case.
October 8, 2009

Updated October 10, 2009

Here are some sample files of varying levels of "readability:
TheBookofOneSyllable.txt, war-of-the-worlds.txt, constitution.txt, critique-of-practical-reason.txt.
(Note: The last of these, the Critique, is quite long, and take almost 15 seconds on my laptop. If it takes your program more than a minute or two, you are probably trying to work with extremely long strings.)

Below are examples of the numbers you should be getting.

    def testAllMeasures(self):
        text = ['This is a simple sentence. This is a more',
                'complicated sentence. This sentence is ',
                'incredibly complicated and polysyllabic.']
        self.assertAlmostEqual(8.383332, getKincaidMeasure(), 3)
        self.assertAlmostEqual(7.99833,  getARImeasure(), 3)
        self.assertAlmostEqual(12.33278, getColemanLiauMeasure(), 3)
        self.assertAlmostEqual(11.28888, getGunningFogMeasure(), 3)
        self.assertAlmostEqual(9.725611, getSmogMeasure(), 3)
        self.assertAlmostEqual(45.64501, getFleschMeasure(), 3)
        self.assertAlmostEqual(50.44444, getLixMeasure(), 3)
Corrected and expanded sample data
TheBookofOneSyllable.txt war-of-the-worlds.txt constitution.txt critique-of-practical-reason.txt
totalWordCount =  16086
totalComplexWordCount =  12
totalLetterCount =  55701
totalSentenceCount =  972
totalBigWordCount =  596
totalSyllableCount =  16140

Kincaid      2.704
ARI          3.154
ColemanLiau  2.813
GunningFog   6.650
SMOG         3.764
Flesch       105.153
Lix          20.254
totalWordCount =  2279
totalComplexWordCount =  252
totalLetterCount =  10344
totalSentenceCount =  95
totalBigWordCount =  660
totalSyllableCount =  3314

Kincaid      10.925
ARI          11.943
ColemanLiau  9.704
GunningFog   14.019
SMOG         12.433
Flesch       59.465
Lix          52.950
totalWordCount =  7541
totalComplexWordCount =  1080
totalLetterCount =  36007
totalSentenceCount =  175
totalBigWordCount =  2557
totalSyllableCount =  11618

Kincaid      19.395
ARI          22.605
ColemanLiau  11.639
GunningFog   22.965
SMOG         17.321
Flesch       32.759
Lix          76.999
totalWordCount =  62719
totalComplexWordCount =  10079
totalLetterCount =  292489
totalSentenceCount =  1421
totalBigWordCount =  19627
totalSyllableCount =  98992

Kincaid      20.248
ARI          22.604
ColemanLiau  11.000
GunningFog   24.083
SMOG         18.344
Flesch       28.508
Lix          75.431
October 7, 2009 The deadline for the Readability assignment is moved to midnight Sunday. Nevertheless, we will have lab and an new assignment this Friday.
October 7, 2009

Sample code involving classes:

  • and, basically from the textbook.
  • --This is a refactoring1 of the program. A Card class is defined, and a new object of this class is constructed2 for each individual flash card.
  • -- This adds to the Card class some instance variables3 and instance methods4 to keep track of how many times this flash card was answered correctly and answered incorrectly.
  • -- This adds a class variable5, presentations, to the Card class, and class methods6 for incrementing it and reporting its value.


  1. Refactoring is rewriting code to improve it, without changing in any way what the code does.
  2. To construct an object is to use the class definition to make a new object.
  3. An instance variable is a variable belonging to a particular object (instance). The class definition determines what the instance variables will be, but each new object gets its own copy of those variables.
  4. An instance method is a method used by an object (instance). Within the method, the object refers to itself and its objects with the variable conventionally named self.
  5. A class variable is a variable associated with the class itself, not with individual instances. There is only a single copy of each class variable.
  6. A class method is a method executed by the class itself, not by any individual instance of the class. Instead of the variable self, used to refer to an instance, the class can refer to itself with the conventionally named cls variable.
October 6, 2009 By popular demand Smiley, I've posted my solutions to the first three assignments:,, and and (Right-click to download; left-click to take your browser's default action.)
October 5, 2009

Dear MCIT students and any friends/guests/etc....

Our next event will be to watch Fermat's Last Tango together over self-brought dinner. Snacks and drinks will be provided.

Fermat's Last Tango
6:20pm Thursday October 8, 2009
Levine 315

This movie is a silly musical comedy, written for the "General Public" (not just mathematicians... but there are a few math-only jokes thrown in as well...) This link tells you more about this very silly musical. See you there!

--Dr. Dietz

October 4, 2009 Made some further updates to the corrections and the Readability assignment. Important note: In the main() method, I've also asked for some additional information to be printed.
October 3, 2009 I've posted some corrections to the Readability assignment.
October 1, 2009 I've added pages about Grading Criteria and Style Rules.
October 1, 2009

In response to student questions:

  • When you pair program, please turn in only one copy of your assignment, with both your names on it. (If for some reason you didn't get a partner, please indicate this fact.)
  • Turn in your test file(s) along with the code being tested (zip all files and turn in the zipped file). Testing is part of this and future assignments, and you will be graded in part on the quality of your tests.
September 28, 2009

Clarifications (Playfair Cipher):

  • Put an x between double letters only as nee
  • ded to break up a pair.
    Example: This message --> th is me sx sa ge ...
    But: The message --> th em es sa ge
  • If the last letter isn't in a pair, you should add an x: super --> su pe rx
    But this would be a bad idea if the last letter is an x: The ox --> th eo x?
    I haven't told you what to do in this case, and the general rule for the course is, If I don't say what to do, it's up to you--but do something reasonable! When we test your code, we can't look for any specific encoding, but we can test that, for instance, your code doesn't go into an infinite loop.
September 26, 2009 Newly discovered web site: I've only explored it a little bit so far, but it looks like a very nice Python resource.
September 25, 2009 Here are some programming suggestions. In it I talk about the Playfair assignment, but the advice applies to all programs.
September 24, 2009

I have posted my writeup on Unit Testing and TDD.

I had a link to someone else's writeup on TDD, but that page seems to have disappeared. To replace it, I've linked to a page on TDD in a wiki. Please read as far as the comments (starting at the book image). There are a lot of interesting links here, which you can ignore but might find interesting. Note: When an article talks about a "green bar" or "red bar," they assume the testing is done from a graphical framework (green = all tests passed), which we don't currently have.

September 23, 2009 Error in code below! The file.close() must be just outside the while loop, not inside it.
September 21, 2009 I think it is now possible to submit your FlashCards assignment via Blackboard. (Sorry for the delay--I'm still not used to the extra steps in the new "improved" Blackboard.)
September 19, 2009 Here's a version of readFlashCards that removes troublesome line endings. It also ignores blank lines. (Changes are in red.)
def readFlashCards(fileName):
    flashCards = []
    file = open(fileName)
    flashCard = file.readline()
    while flashCard:
        flashCard = flashCard.strip() # remove line endings
        if len(flashCard) > 0:     # ignore blank lines
            flashCards.append(eval(flashCard)) # notice the 'eval'
        flashCard = file.readline()
        file.close()  # this line must be further to the left!
    return flashCards
September 17, 2009

Response from Penn Libraries:

Blackboard has been experiencing some system wide problems with uploading documents recently. The problem seems to especially affect users of Firefox. The current workaround is to use Internet Explorer after updating your machine to the most recent version of Java.

Java can be downloaded here:

If this does not resolve the issue, please ask the affected students to email us directly so we can troubleshoot the issue further. Emails can be sent to

September 17, 2009 The Engineering Library now has a copy of the textbook (Budd, Exploring Python, QA76.73 P98 B84 2010) on reserve for CIT 591.
September 17, 2009

The following is from Karl E. Morris, at CETS:

Some students have reported problems when trying to login to the Linux workstations in the lab. The solution is for the student to run virgin on their account to reset the account so that KDE will not fail while logging in.

The user should follow these steps:

  1. From within another user's logged in terminal: ssh
  2. At the command prompt (%) type: %virgin
  3. The user should now be able to login directly to their own account.

The user can also login to a Windows workstation in the computer lab, open a session using SecureCRT to eniac.seas, login to their account and run virgin.

September 16, 2009

Pizza party!

Thursday, September 17, 6 p.m.
Levine 307

Who is invited: All current and former MCIT students and faculty, and students taking MCIT classes. OK to bring a guest.

September 16, 2009

Beginner's section 4:45-? Today (Wednesday), in Jaffe B17.
Map to Jaffe

September 15, 2009 As you probably know, we have already had confirmed cases of swine flu in SEAS. Please take some time to read the instructions at
September 15, 2009

Submitting assignments via Blackboard (ignore last year's instructions):

  1. Go to Blackboard and click on CIT 591-001 2009C.
  2. Click the  Assignments  tab.
  3. Click View/Complete Assignment: Assignment name.
  4. From here on, it should be fairly obvious how to upload and Submit your assignment.

Important changes from past years:

  • I have to post the assignment via Blackboard before you can submit your solution.
  • You can only submit once. If you need to change your submission, you have to contact me or the TA and ask us to discard your previous submission.
  • When you submit, you can submit more than one file for the assignment.
    • However, we don't want to have to download more than one file; so to submit multiple files, please zip them and submit the zipped file.
    • Note: "Zip" means .zip, not .rar or .tar or some other random format that we may or may not be able to open easily.
September 14, 2009

Avi will hold office hours in Moore 207 today, from 5:15 to 7:00.

I will have the first "Beginner's section" this Wednesday, starting at 4:45; the room hasn't yet been assigned.

These may or may not become regular times; our schedules are still being determined.

September 10, 2009 The library has scanned in the first two chapters of the Python book for us, and I have posted them on Blackboard, under "Course Documents."

Note: I have added to Blackboard all the students who were on the waiting list and were admitted.

Please note: In order to use the computers in Moore 207, (1) you must register for this course, and (2) once you are registered, CETS has to set the permissions for you. This doesn't happen instantly.

If you have only recently registered, go to the lab well before class time, and see whether you can log in. If you cannot, contact CETS. Please don't bother them unnecessarily, as this is a very busy time for them.
September 10, 2009 Note that in the Links table below, I have added a link to the Errata for Python book. This page will be updated without notice as additional corrections are found.
Before classes started
Unless otherwise noted, assignments will be made each Friday in Lab, and will be due 6AM the following Friday.

Once we begin pair programming, there will be a 5 point penalty if you miss lab or are sufficiently late that I reassign your partner. You can avoid this penalty if you give me sufficient advance warning (several hours) that you will miss or be late.