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
This week you will complete the following activities
- Monday in-class - How to read from a file
- Monday after class - Read Chapter 8
- Wednesday in-class - How to write to a file
- Wednesday after class -
- Friday in-class - CD #4 in our regular classroom
- Friday after class -