← VCE Applied Computing U1O2

AI-based code generators

A tool that writes program code from a plain-language description or by suggesting the next lines as you type. It can save time, but a person must still check the code.

Understanding AI-based code generators in VCE Applied Computing U1O2

What it does: The AI produces a draft quickly, but the student must still run tests to check it works. A clear plain-language description gives the AI the detail it needs, because it cannot guess what you want. Chat-based generators take a written request and reply with code. Code completion suggests lines as you type in the editor. The programmer stays responsible for checking that generated code works, is safe and meets the task. Code that runs may still give wrong results. Always test it against the requirements with sample data. You still need to understand the code so you can check, fix and maintain it.

Common mistakes: The print call is missing its closing bracket, so the code will not run. It should be print(add(2, 3)). Check AI-generated code for small syntax slips like this. An average is the total divided by the count, so it should use / not *. A code completion suggestion can look right but be wrong, so a person must check it.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 89–124) and word search (Modules 8–124).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which describes an AI code generator?
A tool that writes code from a plain-language descriptionA tool that only fixes spelling mistakes in comments
Matches
# AI wrote this, so it must be correct use_code(ai_output)
↓
Using AI code without checking it. A person must still read, test and fix the generated code.
Applying
Meanings
Term
AI code generator
Meaning
A tool that writes program code from a plain-language description or by suggesting the next lines as you type. It can save time, but a person must still check the code.
Practice
def double(n):
Testing
Gaps
a + b
Check Answer
Spots
3 return a + b
4print(add(2, 3)

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Armadillo' badge — Shield Bearer, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which describes an AI code generator?
A. A tool that only fixes spelling mistakes in comments
B. A tool that writes code from a plain-language description ✓
An AI code generator produces program code from a description you type in plain English, or by suggesting what comes next.
2. A student types 'make a function that averages a list' into a chat tool. What is this?
A. A chat-based code generator ✓
B. A code completion feature
Chat-based generators take a written request and reply with code. Code completion suggests lines as you type in the editor.
3. As you type def calc_total( in your editor, grey text suggests the rest of the line. What is this?
A. A chat-based generator
B. Code completion ✓
Code completion suggests the next lines of code inside the editor while you type, without you writing a separate chat message.
4. What can an AI code generator do?
A. Draft code quickly that you can then test and edit ✓
B. Guarantee the code has no errors
Generators can save time by drafting code, but they can make mistakes, so a person must still test and check it.
5. What can an AI code generator NOT do?
A. Take responsibility for whether the code is correct ✓
B. Suggest code from a short description
The programmer stays responsible for checking that generated code works, is safe and meets the task.

Match the Pairs

Write a Python function that checks if a number is prime → A chat-based generator turns a plain-language request like this into program code
def total_price(items): # editor suggests next line → Code completion in an editor suggests the next lines as you type
An AI code generator can save time by writing a first draft of code, but a person must still test it → result = ai_draft(); run_tests(result)
An AI code generator cannot be trusted to know your exact needs, so you must give a clear description → prompt = "Write a function that adds GST to a price"
# AI wrote this, so it must be correct use_code(ai_output) → Using AI code without checking it. A person must still read, test and fix the generated code.
prompt = "Make my game" → The description is too vague. A generator needs a clear, detailed plain-language request to give useful code.

Key Term

AI code generator
A tool that writes program code from a plain-language description or by suggesting the next lines as you type. It can save time, but a person must still check the code.

Fill in the Blanks

1. # AI suggestion: add two numbers def total(a, b): return a + b
Hint: Type the keyword that sends a value back from a function.
2. # Prompt: show every item in a list for item in items: print(item)
Hint: Type the function that displays output on the screen.
3. # Test the AI code before using it result = total(2, 3) assert result == 5
Hint: Type the keyword that checks a condition is true and raises an error if it is not.
4. # AI suggestion: check for an adult if age >= 18: print("Adult")
Hint: Type the comparison operator meaning greater than or equal to.
5. # AI suggestion: count from 1 to 5 for i in range(1, 6): print(i)
Hint: Type the function that produces a sequence of numbers for a loop.

Spot the Error

Question 1
A # AI-made: add two numbers
B def add(a, b):
C return a + b
D print(add(2, 3)
Line D — The print call is missing its closing bracket, so the code will not run. It should be print(add(2, 3)). Check AI-generated code for small syntax slips like this.
Question 2
A def average(nums):
B total = sum(nums)
C return total * len(nums)
Line C — An average is the total divided by the count, so it should use / not *. A code completion suggestion can look right but be wrong, so a person must check it.
Question 3
A def is_even(n):
B return n % 2 == 0
C if is_even[4]:
D print("Even")
Line C — A function is called with round brackets, not square brackets. It should be if is_even(4):. Chat-based generators can make small mistakes, so run and read the code.
Question 4
A function greet(name):
B return "Hi " + name
C print(greet("Sam"))
Line A — Python defines a function with def, not function. That is JavaScript. AI code generators can mix up languages, so check the code matches the language you asked for.
Question 5
A def double(x):
B return x * 2
C assert double(4) = 8
D print("Test passed")
Line C — A single = assigns a value; it does not compare. The test should use == to compare. Testing AI-generated code like this shows whether it works.

Student with a class code? Join your class →