Summary
In this lesson, you learned that:
- An assistant can make up a name that fits: a method, a function, a library's function. This is called a hallucination, and it's written just as surely as the rest. A name that doesn't exist stops the program with an error such as
AttributeError. - Send the assistant the program and what it printed, and ask for a version with only what you know: every name in it is then one you can check.
- Some errors say that something isn't here, not that it doesn't exist:
FileNotFoundErrorfor a file,ModuleNotFoundErrorfor a library. Only you know where your program runs, so say it. - An assistant knows Python and its libraries as they were in the texts it learned from. When code for a library says a name doesn't exist, look it up in the documentation of your version, and tell the assistant which version you have.
- A claim about how Python works is checked by running it: an experiment of a few lines, on data where you know the answer. Asking the assistant whether it's sure gets you more words, not a result.
Practice it all at once. The program in the editor is another answer someone got, this time for Mia's longest walk. Her walks last week were 40, 25, 55 and 30 minutes. The error it ends with shows one thing wrong with it, and that isn't the only one.
Next comes a small project, Checkpoint: The Week's Report, where you build Mia's report for a week in steps and check it with tests.
Instructions
- 1
Run the program, attach
script.pyand what it printed, and say where the program runs. Give Mia's walks, and ask for a version that works there. Then send it. - 2
Paste the program from the answer in place of yours and run it. It prints
Walks: 4andLongest: 55.