@extends('template')
@section('title')
Lab 9 Tracing & Files
@stop
@section('content')
# Lab 9 Tracing and Files
{{--
## Solutions
--}}
{{--
[Worksheet Solutions](https://docs.google.com/document/d/131QeSav3J-PsZiffbuOXKz9zz-sg_7Mdexr4vIyw9-w/edit?usp=sharing)
--}}
{{--
[Solutions](/content/labs/lab09/solutions)
--}}
## Summary
This lab will give you practice with tracing by adding `print`s to your
code, as well as some exercises on file operations.
@include('/labs/_setup', ['folder' => 'lab09'])
@include('/labs/lab09/_toc')
## Big Questions {.bigqs}
- What are the benefits of writing tests for your code?
Show Answer
The 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 Answer
Data 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.
@stop