Skip to main content

2.10. Programming: Assistance in selected tasks

Learn to program code without AI writing code

Subject: Programming  ·  Grade: 9 (age 14–15)  ·  Duration: 1 double lesson (90 min) ·  AI: Assistance WITH AI 

AI-related competencies (DUAL.AI.TEACHer Framework) – teacher level Subject-specific learning objectives – student/learner level

AF-TL-2b

(AI foundations and applications × Teaching & Learning, Level 2 – Reflective Implementation):

 

“Teachers can organise lesson elements that embed AI use with clear pedagogical roles and strategies to verify the output elements.”


 

AF-FC-2b

(AI foundations and applications × Facilitating Learners’ (AI) Digital Competence, Level 2 – Reflective Implementation):

 

“Teachers can implement guidance that helps learners developing practical AI skills, adapting the tasks to learners’ prior knowledge and the AI tools available.”

 

By the end of the lesson, students can:

  • know how to use AI to do repetitive or supportive tasks in programming, like indenting the code or writing the comments

  • ask an AI model to propose improvements in the code, without giving the code itself, so students can auto-evaluate their knowledge

  • critically evaluate the AI model when asking it how it will optimize the given code

Take-home message: Students need to know the basics of programming if they want to evaluate the results given by a model. So students in the first steps of learning programming must use AI models to do supportive and repetitive tasks related with programming, but not use them to produce code. They can also use the model to ask for possible improvements in the code, so students can test their programming abilities.

imagen.png

Fig 1. Image generated with Gemini (3.6 Thinking), September 8, 2026.

Content

Programming education is changing in a context where AI systems can generate, explain, and review code. While these tools offer new opportunities for learning, they also introduce an important educational challenge: students need sufficient programming knowledge to evaluate whether an AI-generated suggestion is correct, efficient, or even relevant to the task at hand. Without a basic understanding of programming concepts, students may accept incorrect solutions, overlook errors, or fail to recognize better alternatives. For this reason, learning programming fundamentals remains essential, even when AI tools are available.


In introductory programming courses, AI should be positioned as a learning support tool rather than as a substitute programmer. Students can use AI effectively for repetitive or low-level tasks that do not reduce the cognitive effort involved in learning to program. Examples include formatting and indenting code, generating documentation comments, explaining error messages, summarizing syntax rules, or helping students understand the purpose of specific programming constructs. These uses allow students to focus their attention on the underlying logic, algorithms, and problem-solving processes that are central to programming competence.


Another productive use of AI is code review. Instead of asking an AI model to write a solution, students can write their own code first and then ask the model to identify potential improvements. The AI might suggest clearer variable names, better code organization, reduced redundancy, improved readability, or alternative approaches that the student can evaluate independently. This transforms the AI into a feedback partner, allowing students to compare their own reasoning with external suggestions and assess the strengths and weaknesses of their solutions.


However, AI-generated feedback should not be accepted uncritically. Models may recommend changes that are unnecessary, inefficient, or based on incorrect assumptions about the code's purpose. A central goal of this lesson is therefore to develop students' ability to critically evaluate AI suggestions. Students will learn to ask an AI model not only what improvements it proposes, but also why it considers those changes beneficial. By comparing the model's reasoning to established programming principles, students can judge whether the proposed optimization genuinely improves the code or merely represents a different design choice.


This lesson treats AI as a tool that supports reflection, self-assessment, and code quality improvement rather than code generation. Students practice writing their own programs, using AI to perform supportive tasks, requesting feedback on their work, and critically analyzing the quality of the responses they receive. The ultimate objective is to help students become both better programmers and more informed users of AI systems.


Lesson plan

Phase Time Activity
Introduction 810 min The teachersteacher showspresents two short code solutions to the same problem, one written by a student and one generated by an unlabelledAI graphmodel. ofStudents adiscuss realwhich predator–preysolution dataappears seriesclearer, (e.g.more lynx/hare);efficient, studentsor describeeasier theto pattern and form first hypotheses.understand.
Input 1210 min The teacher introduces appropriate uses of AI in programming education, emphasizing the model’sdistinction variablesbetween support tasks, code review, and parameterscode using a simple diagram (no differential equations needed).generation.
Exploration 15 min Students test their hypotheseswork in pairs on a ready-madesmall HTMLprogramming simulationexercise and recordidentify which tasks could appropriately be delegated to an AI assistant and which should remain their observations.responsibility.
Adaptation

Improvement Cycle

35 min InStudents pairs,write studentstheir workown throughsolution 2–and complete 2 to 3 rounds of predictwritepromptasktestevaluatediagnoserevise, (guidingusing questionsAI below),only eachfor timesupportive askingtasks theand LLMimprovement to add one more layer of ecological realism to the simulation (a limit on the prey's food supply, a second species, a seasonal/abiotic factor) until the clean two-variable cycle visibly breaks down.suggestions.
Reflection 20 min Whole-class discussion,discussion guided by questions such as: At which round didabout the simulation stop producing a clean, repeating cycle? What does the original model deliberately leave out,usefulness and why?limitations Whatof makesAI itfeedback, afocusing usefulon simplificationhow ratherstudents thandetermined simplywhether asuggestions wrongwere one?valuable or not.

 

Guiding questions: layering complexity

PairsStudents work through as many of the following rounds as time allows induring the 3535-minute minutesImprovement (most manage two; the third is an extension for early finishers).Cycle. Each round follows the same four-step cycle:process: Write → Ask → Evaluate → Revise

  1. Round 1 — limitUsing theAI prey'sfor foodSupportive supply (a carrying capacity):Tasks
    • Predict:Write: BeforeComplete youa startshort prompting,programming aksexercise yourself:independently.
    what
  2. Ask: doRequest yousupport expectfrom tothe happenAI for a non-programming task related to the cyclecode, ifsuch theas: prey's
    growth
  3. improving slows down once the population gets large, instead of growing without limit? Sketch the curve you expect.indentation,
  4. Prompt:generating Askcomments,
explaining an error message, describing what a function does. Evaluate: Does the AI toexplanation addaccurately a maximum sustainable prey population todescribe the simulation,code? Are the generated comments useful and tounderstandable? explainRevise: inIncorporate itsany helpful changes while ensuring that the program logic remains entirely your own words how it changed the growth equation to do this. Test & compare: Run the new simulation with the same starting values as before. Compare the previous simulation with the new one: how did the variables change? Why is that? Diagnose: Which assumption of the original model (unlimited food for the prey) did you just remove? Is this factor biotic or abiotic?work. Round 2 — addRequesting anotherImprovement (biotic or abiotic) factor:Suggestions
  • Predict:Write: IfReview ayour thirdcompleted speciesprogram nowand competesidentify withparts thethat preycould forpotentially food,be or preys on it as well, or if prey growth now depends on temperature what do you expect this to do to the original two-species cycle?improved.
  • Prompt:Ask: ChooseRequest anotherimprovement factorsuggestions andwithout write a prompt askingallowing the AI to addrewrite itthe ascode. aFor newexample:
variable linked

"Suggest three ways to theimprove existingthis onesprogram's readability specifyand exactlymaintainability, howbut itdo shouldnot interactprovide withreplacement thecode."

prey or predator population.
  1. Test & compare: Observe the simulation over several cycles. Does the original two-species rhythm survive, get distorted, or disappear?
    • Diagnose:Evaluate: TheWhich originalsuggestions modelseem assumedvaluable? eachWhich populationsuggestions dependswould onlyhave little impact on the other.program?
IsRevise: thatImplement any improvements you agree with and test whether the program still truebehaves after this round? What real ecological relationship does your new factor represent.correctly. Optional roundRound 3 — introduceCritically randomness:Evaluating Optimization Advice
  • Predict:Write: If one parameter (e.g. the predation rate) is no longer fixed but drawn randomly withinSelect a range at each time step, what do you expect for the long-term stabilitysection of theyour populations?code that performs a repetitive task or uses loops.
  • Prompt:Ask: AskRequest optimization suggestions and require the AI to replacejustify oneits constant parameter with a randomised value and to keep track of whether either population reaches zero.
Test & compare: Run the simulation several times with the same settings. Do you get the same result every time? Does either population ever collapse? Diagnose: Why can the same “average” parameter values sometimes lead to extinction here, when the deterministic model never predicted that?recommendations.

Example prompt:

"Explain how this code could be optimized and why each proposed optimization would improve performance or readability. Do not provide the optimized code."

      Evaluate: Are the proposed optimizations actually beneficial? Which ones are supported by clear reasoning? Which ones appear unnecessary or difficult to justify? Revise: Decide which recommendations to implement and explain your reasoning.

       

      Reflection Questions:

        Which AI suggestions were most useful for improving your code? Did the AI provide any suggestions that you disagreed with? Why? How did you determine whether an optimization was worthwhile? When is AI most helpful during the programming process? Which programming tasks should still be performed by the student? Why is programming knowledge necessary for evaluating AI-generated feedback? How can students avoid becoming overly dependent on AI tools when learning programming? 

         

        Closing question (for the Reflect phase):

        At

        How whichmuch roundprogramming didknowledge theis simulationnecessary stopto producingdetermine whether an AI suggestion actually improves a clean, repeating cycle —program, and what doesrisks thatarise tellwhen youusers aboutrely howon manyAI-generated real-worldadvice factorswithout understanding the originalcode Lotka–Volterrathemselves?

        model

         has to leave out in order to stay solvable and easy to interpret?

        Materials

        • One laptop per student pair,pair with a browserprogramming environment
        • Access to an LLMAI chat interface via the internet,assistant or a locally installedhosted language model if internet access is restricted at school
        Ready-made HTML predator–prey simulation (single file, sliders for selected parameters) A short promptingprogramming /exercise appropriate to students' experience level A worksheet template forfollowing the “layeringcycle complexity” rounds (predictwritepromptasktestevaluatediagnose)revise GuidingReflection questions forfocused theon explorationAI phaseliteracy and thecritical Nature-of-Scienceevaluation reflection (modelOptional purposecode vs.examples modelillustrating limits)good and poor coding practices