This lab will give you practice with tracing by adding
- Find your partner
- Download lab09.zip which includes the starter code for today's exercises
- Extract that zip file and move the resulting
lab09folder into your
cs111directory on your desktop.
- Open Thonny and view the
Table of Contents
- What are the benefits of writing tests for your code?
Show AnswerThe primary benefit is developing a deeper understanding of the problem you're trying to solve, by forcing you to think concretely about how a solution will behave, and what the edge cases might be. Of course, another important benefit is being able to build confidence that your solution actually works, and being able to quickly check before submitting your code that it's all working and nothing that you did later broke an earlier function you wrote.
- What's the biggest difference between data stored in Python variables and data stored in a file?
Show AnswerData in Python variables has a type associated with it, and some data types can have complex structures, like lists, so you can represent all sorts of things in a way that the programming language can easily use. In contrast, data stored in a file is essentially just one big string, with no opportunity to organize it. The string can have some kind of internal format, especially using newlines to separate things and perhaps something like a comma or tab to separate items on each line. But for this format to be used in a program, the program has to do the work of converting it to a real data structure (like a list of tuples) before it can be operated on easily using tools like loops.