Skip to content
Edition NigeriaGlobal
Country

You are in the Nigeria edition. Type your country to switch.

Set up your 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.

Beginner12 min read6 steps

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 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.

Up next

Skills for the AI ageSpreadsheet basics: cells, range…Read nowSpreadsheet basics: cells, ranges and formulasSkills for the AI age · Beginner · 15 minSkills for the AI ageIF, SUMIFS and COUNTIFSRead nowIF, SUMIFS and COUNTIFSSkills for the AI age · Beginner · 15 minSkills for the AI ageLookups: XLOOKUP, VLOOKUP and IN…Read nowLookups: XLOOKUP, VLOOKUP and INDEX MATCHSkills for the AI age · Beginner · 15 minSkills for the AI ageCleaning data: text, dates, dupl…Read nowCleaning data: text, dates, duplicates and tidy tablesSkills for the AI age · Beginner · 15 minAI at workCoding help for non-developers a…Read nowCoding help for non-developers and developersAI at work · Beginner · 15 minAI at workNatural-language questions and SQLRead nowNatural-language questions and SQLAI at work · Intermediate · 15 minFinancial data & analyticsLab 2: computing returns in codeRead nowLab 2: computing returns in codeFinancial data & analytics · Advanced · 15 minSkills for the AI agePython basics: variables, lists,…Read nowPython basics: variables, lists, loops and functionsSkills for the AI age · Beginner · 15 minSkills for the AI ageUsing AI assistants in spreadshe…Read nowUsing AI assistants in spreadsheets safelySkills for the AI age · Beginner · 15 minSkills for the AI agepandas basics and a first chartRead nowpandas basics and a first chartSkills for the AI age · Beginner · 15 minSkills for the AI ageNo-code workflows: triggers, act…Read nowNo-code workflows: triggers, actions, conditions and dataSkills for the AI age · Advanced · 15 minSkills for the AI ageSQL basics: SELECT, WHERE and OR…Read nowSQL basics: SELECT, WHERE and ORDER BYSkills for the AI age · Beginner · 15 min
English