Summary
In this lesson, you learned that:
- The AI sees only what you send it, not your editor or your console. An attached program goes as it is at that moment, so attach it again after you change it.
- An explanation is only as good as you can follow it. Say what you know and what's new to you, and ask for the program line by line.
- Ask about one thing with a case, such as what a function gives for 60 minutes, and you get every step with numbers you can check.
- When an answer uses something you haven't learned, you can ask for the same program without it, using what you know.
- A program can confirm what the AI says about it: run it, and add a line that prints what you asked about.
Practice it all at once. The program in the editor adds up Mia's walks and prints the time in hours and minutes, with a function you haven't met: divmod().
Next comes Say What the Code Should Do: how to ask for code so that you get the code you need.
Instructions
- 1
Attach
script.py, say that you know//and%but notdivmod(), and ask what the line withdivmod()does with these walks, worked out with the numbers. Then send it. - 2
Check it by running the program. Then add a walk of
25minutes at the end of the list and run it again: the walks now add up to exactly three hours, and the program printsTime: 3 h 0 min.