Using AI coding assistants wisely

Get useful code from AI assistants, check it properly, and keep company and customer data safe.

Module 6: Working smarter and next steps · Lesson 17 of 18 · 16 min read · Free

AI assistants like ChatGPT, Claude and Gemini, and the AI built into Colab, write Python well. For a beginner they're like a patient tutor who's awake at 2am. They also make mistakes, confidently, and they don't know your data unless you tell them. Used well, they make you much faster. Used blindly, they put wrong numbers into reports with your name on them.

Ask well

Good answers come from specific questions. Tell the assistant:

  • What your data looks like: the column names and types, and two or three example rows, with made-up values if the real ones are sensitive.
  • What you want: the exact output, like "a table of paid revenue per branch, highest first".
  • What you're using: "pandas in Google Colab".

I have a pandas DataFrame df with columns order_id, date (text like 2026-03-05), branch, product, qty (int), unit_price (int) and status ("Paid", "Cancelled", "Pending"). Write code to show paid revenue (qty × unit_price) per month, in calendar order, and the % change from each month to the next.

When you get an error, paste the code and the full error message, and say what you expected to happen.

Check everything

How to check code from an AI assistant
  • Read every line before you run it. If you can't explain what a line does, ask the assistant to explain it, or look it up. You're responsible for what your code does.
  • Check the numbers against something you know. If you know the total paid revenue is ₦102,921,600, the per-branch totals must add up to that. If you know there are 900 rows, a result based on 1,800 means something got doubled.
  • Watch for quiet mistakes: filtering the wrong status, counting cancelled orders as sales, sorting months alphabetically, dropping rows you needed, or using a column that doesn't exist in your data.
  • Run it on a small sample you can check by hand first.

Keep data safe

Sales records, customer names, phone numbers, account numbers and salaries are not yours to share. Before you paste anything into an AI tool:

  • Check your company's rules. Some companies approve specific tools; some ban them for client data.
  • Share column names and fake example rows, not the real file. The assistant only needs the structure to write the code.
  • Nigeria's Data Protection Act applies to personal data, and a careless paste can breach it.

Check yourself

Answer in your head first, then open each question to see the answer and why.

  1. What should you give an AI assistant to get useful pandas code?

    • A The column names and types, a few example rows (fake if sensitive), and the exact output you want
    • B Just "write Python"
    • C Your company's full customer file
    • D Your password
    Show the answer

    A) The column names and types, a few example rows (fake if sensitive), and the exact output you want — Specific structure and goals give specific, correct code.

  2. AI-written code says total revenue per branch adds up to twice the known total. What's the most likely problem?

    • A Rows have been duplicated or double-counted somewhere in the code
    • B The AI is always right, so the known total is wrong
    • C Python can't add large numbers
    • D Revenue doubles every month
    Show the answer

    A) Rows have been duplicated or double-counted somewhere in the code — Checking results against a known total catches exactly this kind of quiet mistake.

  3. Why shouldn't you paste a real customer file into an AI tool?

    • A It contains personal data that may not be yours to share, and data protection law applies
    • B AI tools can't read CSV files
    • C It makes the code slower
    • D It's always fine to share
    Show the answer

    A) It contains personal data that may not be yours to share, and data protection law applies — Share structure and fake rows instead; the assistant doesn't need real data to write code.

More free lessons: What Python can do for your work · Lists and loops · Loading data and taking a first look · Fixing text and numbers stored as text · Combining many files into one