The Rockford Files



Another important programming construct that we still need to cover is data files.  The Interactive Python tutorial includes a good discussion on working with data files.  However, do not begin this lesson until all of your outstanding work is completed.

Another Reading Assignment?

I have placed the data files qbdata.txt and studentdata.txt in the HS Apps N: drive in the folder amurphy. Copy them both to the folder on your H: drive where your programs are saved.

Then, begin this lesson by reading the entire chapter. Read all of the words. Try all of the code.

By “Try all of the code”, I mean copy, save, and run each of the programs in the tutorial using SPYDER. Those programs are:

  1. ActiveCode 1 (
  2. Active Code 2 (

Save each file in your H: drive.

What about the Exercises?

Yes, we are also going to complete some of the exercises.  Specifically, Exercises 1, 2 and 5.  The good news is that solutions to Exercises #1 and #5 are provided.  You should try to do them yourself first, however.  Here are some notes that you should read before starting the exercises

  • Carefully read and understand each line of code in the solution to Exercise #1.  You will need this knowledge to complete #2. Remember that I have provided the datafile studentdata.txt for you.
  • For Exercise #2, you are somewhat on your own. It may help to write out what you want to do in English first, including how to average a list of numbers. Save this program as
  • Exercise #5 requires the datafile mystery.dat. I have not provided this one for you, however you can save it on your own.  Just copy it to a new file in IDLE and save it with the name mystery.dat. Make sure that the last line of the file is one blank line.  Exercise #5 will not work properly without this file.

We’ll be submitting Exercise #2, with the file name, online when I get the link ready.  When you get #5 working, just call me over to see your mystery image.

Submit your working file with the name using this submission link.