Don't Run What You Can't Read
A program can do more than print. On your computer, it can change and delete your files, and send what's in them over the internet. A program you wrote, you can read. Code from an AI, from a website or from a friend may have lines you haven't learned, and a coding agent asks you to let it run commands you may never have seen. When you can't read it, ask what it does before you run it, and say yes to an agent only once you know what its command does.
Mia keeps all of this year's walks in a file on her computer, walks.txt, with a line for each walk. She asked an AI for a program that saves this week's walks there, and got the one in the editor. You've seen open() read a file in When It Makes Things Up; here it's used in a way you haven't learned, with "w" and write().
Python on this site runs in your browser, which keeps it away from the files on your computer: here, the program can't touch anything of yours. Ask anyway. On Mia's computer, the same lines would work on her real walks.txt, and so would a program an agent runs in your project. The habit you need there is the one you practice here.
Instructions
- 1
Before you click Run, attach
script.pyand ask what the program does, line by line, and what it does to the files on the computer it runs on. Then send it.