Ask across files
The model can see every file. It can change report.py. It cannot change grades.csv, because that file stays as the lesson wrote it.
Ask for the average function. Say which file to read, and say to leave grades.csv alone.
The plus under the file list adds a file when you want one. You can also ask the model to create a file. A new file name is still one segment, such as notes.py. No slash, and no ...
What to put in the prompt
A short ask is easier to check when it names three things.
- The function name:
average. - The file to edit:
report.py. - The file to read and not change:
grades.csv.
Say that average takes no arguments, opens grades.csv, and returns the average of the score column. The modules tutorial is the background for splitting code and data. The csv module is the reader you want the model to use.
A worked example
The kept rows are Ada 10 and Bea 30. Their average is 20. A precise prompt asks for that behavior without pasting a new table.
That function lives in report.py. It imports csv, reads the kept file, and returns 20 for these two rows. You do not have to type it yourself. Ask for it, then run the check.
The prompt box is the place for the request. The :feedback: prompt setting comments on what you asked, not on a rewritten csv file. Use :add: files only if you need another file. This exercise does not need one. report.py is already the entry file.
Name the function, the file to edit, and the file that must stay.
If the reply edits grades.csv, reject that part and ask again for a change only in report.py.
Exercise
Ask for a function named average in report.py. It reads grades.csv and returns the average score. Leave grades.csv unchanged.
Ask for a function named average in report.py. It reads grades.csv and returns the average score. Leave grades.csv unchanged.