Country
You are in the Nigeria edition. Type your country to switch.
Nigeria
Loading every country…
No country matches. Check the spelling, or choose "Any country" for the Global edition.
Your learning profile
Data skills: SQL and Python basics · Lesson 7 of 7
AI as a coding partner: read, test and fix its code
A chat assistant can write SQL and Python in seconds, but it can also be confidently wrong. This lesson shows how to ask for code well, read it line by line, test it on a tiny dataset whose answer you already know, fix the common errors and keep personal or confidential data out of the chat.
This lesson is complete in writing. A video for it is on its way.
What you will learn
- By the end you can write a clear request for SQL or Python code to a chat assistant.
- You can read generated code line by line and say in plain words what each line does.
- You can test code on a tiny dataset whose answer you already know.
- You can recognise and fix wrong column names, off-by-one loops, silent type errors and invented functions, without sharing personal or confidential data.
Key terms in this lesson
- Large language model
- An AI model trained on huge amounts of text to understand and generate language.
- Prompt
- The instructions and material you give an AI model in order to get a response, from a short question to a long brief with pasted documents.
- Off-by-one error
- A common coding mistake where a loop, range or count starts or stops one step too early or too late, so one item is skipped or counted twice.
- Known-answer test
- Running code on a small dataset whose correct result has already been worked out by hand, so any difference between the two exposes a mistake in the code.
- Synthetic data
- Artificial data generated to resemble real data in structure and statistics without describing real people, often used to test formulas, queries and tools safely.
- Silent error
- A mistake that lets code run to the end without any warning but produces a wrong result, such as numbers stored as text being joined instead of added.
- AI hallucination
- A confident answer from an AI tool that is false or made up, such as an invented figure or a source that does not exist.
- Package hallucination
- An AI tool suggesting a software package that does not exist, a name attackers may then register and fill with malicious code.
- Code review
- A structured read of code by a person before it is used, to find errors, security risks and unclear parts, and to confirm it does what was intended.
- Personal data
- Any information that identifies you or could be linked to you, such as your name, account numbers, address, ID number or voice.
- Step 1: Asking for code well, not started
- Step 2: Reading the code line by line, not started
- Step 3: Testing on a known answer, not started
- Step 4: The four errors to look for, not started
- Step 5: Fixing it, with or without the assistant, not started
- Step 6: Keeping data safe, not started
About 11 min of reading
Step 1 of 6
Asking for code well
Opening this step…
Step 2 of 6
Reading the code line by line
This step opens when you finish the one above.
Step 3 of 6
Testing on a known answer
This step opens when you finish the one above.
Step 4 of 6
The four errors to look for
This step opens when you finish the one above.
Step 5 of 6
Fixing it, with or without the assistant
This step opens when you finish the one above.
Step 6 of 6
Keeping data safe
This step opens when you finish the one above.
Key takeaways
The key takeaways open when you finish every step.
Lesson quiz
6 questions. You need 85% to pass.
The quiz opens when you finish every step.
Stockertim Learn is education. It explains how investing works and never recommends buying or selling anything.
Popular this week: Basics: BeginnerNGX & Africa: Beginner