One Piece at a Time
The program in the editor is the one from the last exercise, with total_minutes() and the line that prints it. That piece is done: you ran it and checked the 190 minutes by hand. Now comes the next piece, in the same way.
Running the program after every piece is what makes small steps worth it. Everything you added before was checked when you added it, so when a line of the report comes out wrong, the mistake is in the piece you've just added. In a program pasted in one go, it could be in any line.
This exercise has a chat of its own, which hasn't seen the program or the plan. That doesn't matter: attach the program as it is now, and say which piece you want. The next one is what Mia earned, the price of each walk added up. walk_price() already works out the price of one walk, so the new function only has to call it for every walk.
Instructions
- 1
Attach
script.pyand ask for only the next piece: a functionweek_total(walks)that returns what Mia earned, usingwalk_price()for every walk. Say that you want nothing for the longest walk yet. Then send it. - 2
Paste the function into the editor above
print_report(), and addprint("Total:", week_total(walks))at the end ofprint_report(). Run the program and check the new line by hand: the walks cost 6, 12, 6, 12 and 12, so it printsTotal: 48.