Module 4 · Do the work — and keep your judgement Lesson 13 of 15
Code: draft it, read it, debug it
Use AI as a fast first draft and a patient explainer, never as code you paste without reading. Ask it to explain its own code line by line, to find a bug from the error message, and to show the smallest example first. If you cannot explain the code, you cannot defend it in an interview or maintain it in the job.
The concept
Use AI as a fast first draft and a patient explainer, never as code you paste without reading. Ask it to explain its own code line by line, to find a bug from the error message, and to show the smallest example first. If you cannot explain the code, you cannot defend it in an interview, and you cannot fix it when the data changes.
The mistake is shipping code you cannot read. Break it on purpose — delete a quote, pass a file that does not exist — and read the error before you ask for help. Understanding the error message is a real skill, and this is the cheapest place to build it.
Write a Python function that reads a CSV file and prints the average
of the "marks" column.
Then explain every line as if teaching a beginner.
Finally, tell me what happens if one cell in that column is blank,
and show the smallest change that handles it.import csv
def average_marks(path):
total, count = 0, 0
with open(path, newline="") as f:
for row in csv.DictReader(f):
value = row.get("marks", "").strip()
if value: # skip blank cells
total += float(value)
count += 1
return total / count if count else 0
print(average_marks("students.csv"))Worked example
Write a Python function that reads a CSV and prints the average of the marks column. Then explain every line as if teaching a beginner, and tell me what happens if one cell is blank.
Your practice task
Generate one small script, run it, break it on purpose, and fix it using only the error message.
Do this before moving on. Reading a solution teaches the shape of it; typing it teaches you.
Key takeaway
Use AI as a fast first draft and a patient explainer, never as code you paste without reading.
Keep your place in this course
A free account saves which lessons you have finished and unlocks the certificate. The lesson itself stays free to read.
Create free account or sign inCourse complete
You finished every lesson.
Your certificate is ready, and the projects you built are the proof to attach to an application.
Almost there
15 lessons left of 15
Finish every lesson to unlock the certificate. Each one ends in a practice task — do them and the final project brief writes itself.