Writing a prompt to generate code
A clear AI request stating the language, the task, the inputs and outputs, and the constraints. Keep to one task per prompt, e.g. Write a Python function that returns an average.
Understanding Writing a prompt to generate code in VCE Software Development U3O1
What it does: These lines set limits on the solution (no libraries) and define behaviour for an edge case (empty list), which are requirement and constraint statements. The words 'Python function' name the language, and the prompt also gives the function name, one task and the input, so it shows the language being specified. Naming the language and version means the AI uses syntax and libraries that match your environment. Example inputs and outputs show the AI exactly what result you expect, so it is less likely to guess wrongly. Asking for one task at a time gives code that is easier to read, test and fix. You can build the full program in steps.
Common mistakes: The output is vague. A good code prompt says exactly what comes out, for example 'Output: average as a float.'. The prompt does not name the programming language. It should say 'Write a Python function that' so the AI does not guess.
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 178–193) and word search (Modules 168–193).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
code promptFill in the Blanks
Spot the Error
Student with a class code? Join your class →