Lesson 725 of 1169
Sometimes AI Makes Up Code That Doesn't Actually Work
AI can invent function names that look real but aren't — always test the code.
Explorers · AI-Assisted Coding · ~3 min read
The big idea
AI is so confident that it sometimes invents code that LOOKS right but won't run. It might call a function that doesn't exist or use a tool the wrong way.
Some examples
- AI says 'use the magicSort() function' — but no such function exists.
- Code looks perfect but throws an error the second you run it.
- AI might mix up two different programming languages.
- Always run the code to see if it actually works.
Try it!
Ask AI for a tiny program. Try to run it. If it errors, ask AI to fix it. Try again.
Key terms in this lesson
Practice this safely
Try this with a low-stakes example and a trusted adult nearby. The goal is to notice how AI talks about hallucination, not to let it make the decision for you.
- 1Ask AI to explain hallucination in plain language, then underline anything that sounds uncertain or too broad.
- 2Give it one detail from "Sometimes AI Makes Up Code That Doesn't Actually Work" and ask for two possible next steps plus one reason each step might be wrong.
- 3Check testing against a trusted source, teacher, adult, expert, or original document before you use it.
End-of-lesson quiz
Check what stuck
8 questions · Score saves to your progress.
Lesson help
Questions are best handled with a grown-up here.
For this age range, Tendril keeps freeform AI chat paused until parent/guardian consent and child-safe moderation are fully verified. Use the quiz, notes, and related lessons below, or ask a parent, guardian, teacher, or librarian to work through the question with you.
Progress saved locally in this browser. Sign in to sync across devices.
Related lessons
Keep going
Explorers · 5 min
AI Coders Make Mistakes Too: How to Spot Them
Just like AI can give wrong answers, AI can write buggy code. Here is what to watch for.
Explorers · 5 min
AI Helps You Code a Game Character
How an AI helper helps you design and code a game character.
Explorers · 40 min
How AI Helps Make Sure Code Actually Works
AI can write 'tests' — little checks that make sure your code does what you want.
