Ask About One Thing
When one line puzzles you, ask about that line, with a case: what does it give for 60 minutes? An explanation in general words can sound clear and still leave you unsure. Worked through with one number, it shows you every step, and you can check each of them.
Mia charges £6 for every started half hour: a walk of 30 minutes costs £6, and a walk of 31 minutes costs £12, because the second half hour has started. The function walk_price() in the editor works the price out, and the program prints the price of a 75-minute walk: two half hours and a started third, so 18. You know // and %, but it may not be clear why the function needs both, or what it does with a walk of exactly 60 minutes. Is that two half hours, or has a third one started?
Asking with a number also gives you something to check. What the AI works out for 60 minutes, the program prints when you call the function with 60.
Instructions
- 1
Attach
script.pyand ask whatwalk_price()gives for a walk of exactly 60 minutes: two half hours or three. Ask for it to be worked out with the numbers, line by line. Then send it. - 2
Check the answer: below the line that prints the price of 75 minutes, add one that prints the price of 60 minutes in the same way, and run the program. It prints
Price: 18andPrice: 12.