Hints First
Ask an AI to fix your program, and it fixes it. That's handy when all you need is a program that works. When you're learning to program, it helps less than it seems: you paste the answer, the program runs, and in your next program you make the same mistake, because you never found it yourself. When we sent the message in the chat box with the program in the editor attached, one answer began like this, and then gave the whole program, corrected:
The problem is indentation: the return total line is inside the loop, so the function returns on the first iteration, after adding only the first item (30).
Move the return outside the loop:The same message gets a different answer each time, but every one we got had the corrected program in it.
A tutor helps differently: it tells you where to look and gives you a hint, and you find the mistake yourself. You can make the AI your tutor with instructions. Most AI apps let you write instructions once, in their settings or in a project, and the AI gets them with every message, so you don't have to repeat them. If you've taken the Using AI course, you made a tutor like that for math homework; here, the homework is your own program.
In this exercise, instructions.txt holds the instructions. It goes with every message, so you don't attach it. Good instructions for a tutor say who the AI is to you, what you want to do yourself, what it does instead (where to look, and a hint), and when you do want the code: when you ask for it, for example after you've tried, so that you can compare.
Mia's program in the editor should add up this week's walks, 155 minutes, but it prints Total: 30.
Instructions
- 1
Write in
instructions.txtthat the AI is your programming tutor: you're learning Python and want to fix your programs yourself, so when you ask for help with a program, it doesn't write the corrected code, but tells you where to look and gives you a hint. It gives you the corrected code only when you ask for it. Then attachscript.pyand send the message in the chat box. - 2
Find the mistake with the hint and fix it yourself, keeping the list of walks as it is. Run the program: it prints
Total: 155.