← VCE Applied Computing U1O2

Checking AI-generated code

Read AI-generated code, test it against the requirements and check it for errors, bias and copyright issues before you use it. Then acknowledge the AI tool you used.

Understanding Checking AI-generated code in VCE Applied Computing U1O2

What it does: Reading before running means you understand what each line does. Comments in your own words show that you do. This line treats people differently because of their gender. Checking AI code for bias means finding and removing rules like this. A test table compares expected and actual output for planned test data, including boundary and invalid inputs. One run proves very little. Logic errors do not stop a program from running. Only testing against the requirements shows whether the output is right. The code runs but does not follow the requirement. Testing values such as 11, 12, 18 and 19 reveals this kind of error.

Common mistakes: The code was made by an AI tool, so the comment must acknowledge it, for example '# AI tool: ChatGPT, 3 May 25'. It must not claim the work is all your own. The test table expects 50 to pass, but > 50 returns False for 50. It should be >= 50. Testing boundary values finds this kind of AI error.

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
An AI tool gives you code that solves your task. What should you do first?
Read the code and make sure you understand itPaste it into your project and submit it
Matches
Pasted the AI code into my program and handed it in without running it
↓
The code was not read or tested against the requirements, so errors could remain and the student may not understand it
Applying
Meanings
Term
Check AI code
Meaning
Read AI-generated code, test it against the requirements and check it for errors, bias and copyright issues before you use it. Then acknowledge the AI tool you used.
Practice
def average(marks):
Testing
Gaps
Code generated by ChatGPT, checked by me
Check Answer
Spots
1# Written by me, no AI used
2def average(m):

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

The 'Warthog' badge — Definition Digger, 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. An AI tool gives you code that solves your task. What should you do first?
A. Paste it into your project and submit it
B. Read the code and make sure you understand it ✓
Reading before running means you understand what the code does and can spot problems before they cause harm.
2. Which is the best way to test AI-generated code against the requirements?
A. Use a test table with inputs, expected results and actual results ✓
B. Run it once and assume it works if no error appears
A test table compares expected and actual output for planned test data, including boundary and invalid inputs. One run proves very little.
3. The AI code runs without any error message. What does that tell you?
A. Only that it has no syntax or runtime errors; it may still give wrong results ✓
B. The code is correct and meets every requirement
Logic errors do not stop a program from running. Only testing against the requirements shows whether the output is right.
4. Your program needs to accept ages from 12 to 18. The AI code accepts 11. Which type of error is this?
A. A syntax error that the editor would have flagged
B. A logic error that testing with boundary data should find ✓
The code runs but does not follow the requirement. Testing values such as 11, 12, 18 and 19 reveals this kind of error.
5. Why should you check AI-generated code for bias?
A. It may treat some users or groups unfairly because of its training data ✓
B. AI code is always neutral because a computer wrote it
AI tools learn from existing data, which can contain bias. Check that your code treats all users fairly.

Match the Pairs

# Generated by ChatGPT, checked and edited by me → A comment that acknowledges the AI tool used, and states that the student has checked the code
Test table: input 50, expected 50, actual 45 → A test shows the code does not meet the requirements, because the actual output differs from the expected output
Read the AI code and explain each line before you run it → # Line 3: loop through each mark and add it to total
Check the code for bias, such as unfair rules built into a decision → if gender == "female": discount = 0
Pasted the AI code into my program and handed it in without running it → The code was not read or tested against the requirements, so errors could remain and the student may not understand it
# Code written by me (it was copied from an AI tool) → The AI tool is not acknowledged, so the comment wrongly claims the student wrote it all

Key Term

Check AI code
Read AI-generated code, test it against the requirements and check it for errors, bias and copyright issues before you use it. Then acknowledge the AI tool you used.

Fill in the Blanks

1. # Code generated by ChatGPT, checked by me
Hint: Type the symbol that starts a Python comment, so you can acknowledge the AI tool you used
2. print(average([2, 4, 6])) # expected: 4
Hint: Work out the expected result for the test table by hand before you run the code
3. def average(nums): return sum(nums) / len(nums)
Hint: Read the AI code first: type the function that counts how many items are in the list
4. def average(nums): if len(nums) == 0: return 0
Hint: Type the operator that tests if two values are equal, to catch an empty list error
5. tests = [(2, 3, 5), (0, 0, 0)] for a, b, expected in tests: print(add(a, b) == expected)
Hint: Type the operator that compares the actual result with the expected result

Spot the Error

Question 1
A # Written by me, no AI used
B def average(m):
C return sum(m) / len(m)
Line A — The code was made by an AI tool, so the comment must acknowledge it, for example '# AI tool: ChatGPT, 3 May 25'. It must not claim the work is all your own.
Question 2
A def is_pass(mark):
B return mark > 50
C print(is_pass(50))
D # Test: 50 expects True
Line B — The test table expects 50 to pass, but > 50 returns False for 50. It should be >= 50. Testing boundary values finds this kind of AI error.
Question 3
A # Task: total of 3 prices
B prices = [4, 6, 10]
C total = sum(price)
D print(total)
Line C — Reading the code before running it shows that 'price' is never defined. The list is called 'prices', so it should be sum(prices).
Question 4
A marks = [70, 85, 90]
B total = 0
C for m in marks:
D total = m
E print(total / len(marks))
Line D — This replaces the total with the latest mark instead of adding to it, so the average is wrong. It should be total += m. A test table with a known expected average would catch this.
Question 5
A names = ['Ava', 'Liam', 'Zoe']
B for n in names:
C if n[0] < 'M': print(n)
Line C — This filter quietly leaves out users whose names come after M, which is a bias in the AI code. Every user should be welcomed, so the line should be print('Welcome', n).

Student with a class code? Join your class →