Week 13
File it under AWESOME

Weekly Summary

In my mind, most of what we have done with Python so far is absolutely, 100% necessary. But it is also often kind of boring! It isn't until this week that we really start to do some cool things. This week we want to learn how to use simple text files - well formatted files of simple ASCII characters - to provide our programs with access to "large" amounts of data. Once we know how to read and write from files we have the ability to really do some fascinating things.

 

Learning Outcomes

By the end of the week students should be able to:

  • Explain and/or properly use the following functions that allow us to work with text files:
    • open()
    • close()
    • split()
    • readline()
    • write()
  • Explain the purpose of
    • myString[0:-1] (or myString[:-1] which does the same thing.)
  • Reading Code
    • Given a snippet of code containing one or more of the new functions listed above, indicate the results of the code.
  • Writing Code
    • Given a problem statement that includes the name of a function and the parameters required by that function, as well as the description of a text data file to go with it, write the Python code/definition of the provided function such that it solves the problem by returning correct output values.
  • Debugging Code
    • Given a problem statement and a non-working Python function that attempts to solve the problem, identify where the function is incorrect and explain how to fix it.

 

Learning Materials

Textbook Readings

 

Lecture Videos

 

Practice Materials

Paired Programming Activity

Please complete the following Paired Programming activity with your assigned partner for the week.

 

Additional Textbook Activities

These are great for some additional practice. You should complete these on your own rather than with a partner.

 

Code Walkthroughs

The following are videos and code solutions for the programs discussed in the Paired Programming Activity and Individual Program Activity. You SHOULD NOT view these until you have either solved the activities yourself - and you want to see how I would do it - or you have tried at least two different times and still are stumped. Don't jump to reading the "correct answer" too quickly. I think it is a GOOD thing to struggle with a problem for a day or two. We improve when we meet and overcome resistance. Learning comes from practice. You need to TRY before jumping to the solutions.

 

Graded Materials

The following programs are formally graded as part of the Unit 3 "Problem Set." You should work on these only as an individual. While working on these problems you may refer to your notes, your textbook, any programs you wrote, and even my videos. However, you should limit your discussion of these programs with classmates. It is acceptable to discuss how you solved a problem in grand scheme of things, but you should never show your code to a classmate either as the person who is struggling or as the person who is helping a struggling classmate. You can talk ideas, but not specific solutions.