Summary
In this lesson, you learned that:
- A program you get in one piece is hard to check: when it's wrong, the mistake can be in any line. Build it in small steps instead.
- Start with a plan: the steps in order, each small enough to write and check on its own. Say that you don't want any code yet, or you may get it with the plan.
- Ask for one piece at a time, and say that you want nothing else yet. Paste it, run the program and check the new line by hand before the next piece. Then a wrong line points to the piece you've just added.
- When you ask for a change, say where it goes and what stays as it is, by name. After pasting, check that the rest is as it was.
- The assistant knows your program as it was when it last saw it, so attach it again after you change it yourself. When a chat has grown long, with many versions of the program in it, start a new chat: attach the program as it is now and say in a sentence what it does.
Practice it all at once. Mia would like the report to show what she would have earned without the discount, too. The chat here is new, and the program in the editor is the report as you left it.
Next comes Tests Come First: examples that check a function every time you run the program, written before the function itself.
Instructions
- 1
Attach
script.pyand ask for only that piece: a functionfull_price(walks)that adds up the prices of the walks without the discount, and a line at the end ofprint_report()that prints it afterFull price:. Say thatweek_total()and the rest stay as they are. Then send it. - 2
Paste the function and the line into your program, and run it. The report ends with
Full price: 56, five more than the total.