Leave the Rest as It Is
A program you've built and checked piece by piece is worth keeping as it is. When you ask for a change, an assistant may give you more than you asked for: a new function, a tidier version of one you wrote, a report with lines you didn't want. Pasted in, it changes code you had already checked, and you have to check all of it again.
Mia has made up her mind about a discount: she now gives £5 off a week of five walks or more. Asked just that, with the program attached, one answer added a function of its own for the discount and rewrote print_report(), which then printed two new lines:
Walks: 5
Time: 190 min
Subtotal: 48
Discount: 5
Total: 43The total is right, but it isn't Mia's report anymore, and print_report() isn't the one you checked. Other answers to the same message rewrote print_report() too. So say where the change goes and what stays as it is, by name. Here, the discount belongs in week_total(), and walk_price(), total_minutes() and print_report() stay. After pasting, check that they did.
Instructions
- 1
Attach
script.pyand say where the change goes: onlyweek_total()changes, so that it takes 5 off the total of a week with five walks or more. Say that the rest stays as it is:walk_price(),total_minutes()andprint_report(). Then send it. - 2
Paste the new
week_total()in place of the old one. If the answer has the whole program, compare it with yours before you paste it:print_report()has to printweek_total(walks)afterTotal:, as it did. - 3
Run the program. It prints
Total: 43, five less than before. Don't take the answer's word for the total: one answer said it “goes from 36 to 31”, with the right code and a wrong sum, and other answers got the sum wrong too.