Coding Strategies: Using AI to reduce cognitive load
Reading time: 6 mins
Last updated: 29/06/2025
Last updated: 29/06/2025
Introduction
In the ever-evolving landscape of education, technology continues to play a pivotal role in shaping how students learn and engage with complex subjects. One of the most promising advancements in this area is the use of generative AI to support children with learning to code. By leveraging the power of AI, educators can create dynamic and interactive learning experiences that cater to the diverse needs of students.
Generative AI offers innovative solutions for teaching coding, such as creating Parsons problems, worked examples, and lessons using the PRIMM (Predict, Run, Investigate, Modify, Make) framework. These tools not only reduce cognitive load but also foster a deeper understanding of programming concepts. In this blog post, I will explore how generative AI can be used to support children when learning to code by providing personalised and effective learning aids that enhance student engagement and comprehension.
Generative AI offers innovative solutions for teaching coding, such as creating Parsons problems, worked examples, and lessons using the PRIMM (Predict, Run, Investigate, Modify, Make) framework. These tools not only reduce cognitive load but also foster a deeper understanding of programming concepts. In this blog post, I will explore how generative AI can be used to support children when learning to code by providing personalised and effective learning aids that enhance student engagement and comprehension.
What is cognitive load?
Cognitive load relates to the amount of information that working memory can hold at one time.
New information is first processed by the brain’s limited short-term or working memory, which is typically able to hold two to seven elements at a time. This information is then transferred into the brain’s unlimited long-term memory.
If the brain’s working memory is overloaded with new information, it hampers, reduces, or stops the transfer of information into long-term memory, which is necessary to retain learning.
New information is first processed by the brain’s limited short-term or working memory, which is typically able to hold two to seven elements at a time. This information is then transferred into the brain’s unlimited long-term memory.
If the brain’s working memory is overloaded with new information, it hampers, reduces, or stops the transfer of information into long-term memory, which is necessary to retain learning.
What is Generative AI?
Generative AI is a type of artificial intelligence that can create original content, such as images, music, and text. While some types of AI analyse data to predict future outcomes (as seen in predictive text), generative AI goes a step further. It uses patterns it has learned from data to generate entirely new examples.
AI tools used in this blog post:
AI tools used in this blog post:
- Microsoft 365 Copilot: m365.cloud.microsoft/chat
- Google Gemini: gemini.google.com
- NotebookLM: notebooklm.google.com
- ChatGPT: chatgpt.com
AI prompts
Using AI to create worked examples
Commonly used in a range of subjects, including Maths and Science, worked examples are a form of ‘scaffolding’ designed to help reduce cognitive load placed on novice learners.
When a learner is given a partial (or near complete) solution to a problem, they do not have to rely as much on their long-term memory. Worked examples aim to reduce the superfluous cognitive load often placed on learner’s working memory, when faced with new / complex problems, by providing a model solution to a problem. Worked examples, when used in conjunction with traditional practice problems, can also help learners develop strategies for solving similar problems when faced with them in the future.
How it works:
- Prepare a partial solution to a problem for the students to complete.
- Provide a brief description of what the code is meant to do, this can be in the form of comments or verbal explanation.
- Use sub-goal labelling to identify each of the important steps in the code.
- Add questions / prompts with the aid of comments or annotations.
Example
Commonly used in a range of subjects, including Maths and Science, worked examples are a form of ‘scaffolding’ designed to help reduce cognitive load placed on novice learners.
When a learner is given a partial (or near complete) solution to a problem, they do not have to rely as much on their long-term memory. Worked examples aim to reduce the superfluous cognitive load often placed on learner’s working memory, when faced with new / complex problems, by providing a model solution to a problem. Worked examples, when used in conjunction with traditional practice problems, can also help learners develop strategies for solving similar problems when faced with them in the future.
How it works:
- Prepare a partial solution to a problem for the students to complete.
- Provide a brief description of what the code is meant to do, this can be in the form of comments or verbal explanation.
- Use sub-goal labelling to identify each of the important steps in the code.
- Add questions / prompts with the aid of comments or annotations.
Example
Using generative AI to create worked examples
When leveraging AI to create worked examples, it's most effective to start with a clear description and an initial example. Keep in mind that generative AI is conversational, so use iterative prompting to refine and enhance your results.
Example prompt:
Prompt 1:
Prompt 2:
Prompt 3:
When leveraging AI to create worked examples, it's most effective to start with a clear description and an initial example. Keep in mind that generative AI is conversational, so use iterative prompting to refine and enhance your results.
Example prompt:
Prompt 1:
- Worked examples are a form of scaffolding designed to help reduce cognitive load when teaching children how to code.
How it works:
- Prepare a partial solution to a problem for the students to complete.
- Provide a brief description of what the code is meant to do, this can be in the form of comments or verbal explanation.
- Use sub-goal labelling to identify each of the important steps in the code.
- Add questions / prompts with the aid of comments or annotations.
Prompt 2:
- Here is an example of a worked example for drawing a regular polygon square shape using the turtle library in Python:
#Import the turtle library
import turtle
#Create a new window
window = turtle.Screen()
#Create a new turtle called timmy
timmy = turtle.Turtle()
#Create a square with each side equalling 100 pixels in length
for loopCounter in range( ): #What value goes here?
timmy.forward( ) #what value goes here?
timmy.right(90)
Prompt 3:
- Create a worked example for drawing a regular hexagon shape using the turtle library in Python.
Example response
Faded Examples
As learners become more proficient, the benefits of using worked examples are reduced to the point at which they may start to become a hindrance rather than a help! As with any type of scaffolding and support, worked examples should be faded to provide stretch and challenge.
Imagine a faded example as a sort of fill-in the-blank challenge, but with code. Start by giving students a near complete solution to a problem and challenge them to fill in the blanks. Over time, add more and more blanks until the student is essentially writing the solution for themselves. The following demonstrates a greatly simplified example of a fading using the Turtle library in Python.
As learners become more proficient, the benefits of using worked examples are reduced to the point at which they may start to become a hindrance rather than a help! As with any type of scaffolding and support, worked examples should be faded to provide stretch and challenge.
Imagine a faded example as a sort of fill-in the-blank challenge, but with code. Start by giving students a near complete solution to a problem and challenge them to fill in the blanks. Over time, add more and more blanks until the student is essentially writing the solution for themselves. The following demonstrates a greatly simplified example of a fading using the Turtle library in Python.
AI prompt for creating a faded example:
Prompt:
I’m creating a beginner-friendly coding tutorial using the “faded worked example” technique. This method involves showing students a nearly complete Python code example and gradually removing parts for them to complete.
Please generate a series of 4 faded worked examples for each of the following shapes using the turtle library in Python: Square, Triangle, Pentagon, and Hexagon.
For each shape:
Example response:
Prompt:
I’m creating a beginner-friendly coding tutorial using the “faded worked example” technique. This method involves showing students a nearly complete Python code example and gradually removing parts for them to complete.
Please generate a series of 4 faded worked examples for each of the following shapes using the turtle library in Python: Square, Triangle, Pentagon, and Hexagon.
For each shape:
- Start with a fully worked example.
- Then create 3 progressively faded versions, each with more missing code (e.g., missing lines, parameters, or logic).
- Use comments like # TODO: fill in this line to indicate blanks.
- Format the output in Markdown with code blocks and clear section headers for each shape and each step.
Example response:
Notice that AI has created several faded examples for each shape. If the desired outcome was for each shape to represent a different phase of fading, we can adjust our prompt as follows:
New prompt:
I’m creating a beginner-friendly coding tutorial using the “faded worked example” technique. This method involves showing students a nearly complete Python code example and gradually removing parts for them to complete.
Please generate a progressive series of 4 faded worked examples using the turtle library in Python to draw the following regular polygons:
New prompt:
I’m creating a beginner-friendly coding tutorial using the “faded worked example” technique. This method involves showing students a nearly complete Python code example and gradually removing parts for them to complete.
Please generate a progressive series of 4 faded worked examples using the turtle library in Python to draw the following regular polygons:
- Square (fully worked example)
- Triangle (some lines missing)
- Pentagon (more lines missing)
- Hexagon (minimal code provided)
- Each shape should represent a different phase of fading.
- Use comments like # TODO: fill in this line to indicate missing parts.
- Format the output in Markdown with code blocks and clear section headers for each shape.
- Assume the audience is beginner coders learning how to use loops and turtle graphics.
Using AI to create Parsons Problems
Parsons problems are programming puzzles where a working solution to a problem has been broken up into blocks of code and jumbled up. Students are given the mixed-up code and challenged to re-assemble the code in the correct order. Some Parsons problems, often referred to as two-dimensional Parsons problems, also require the code blocks to be indented correctly. Parsons problems can also contain extra lines of code, called distractors, which are not needed for the code to work.
Although primarily used with text-based languages, Parsons problems can also be used with block-based languages too! The idea behind parson problems is to allow students to focus on the core concepts such as flow of control, conditionals and loops, without the frustration of syntax errors.
Example of a Parsons problem with distractors:
timmy = turtle.Turtle()
window = turtle.Screen()
timmy.forward(100)
timmy.right(90)
timmy.turn(90)
For loopCounter in range(4)
for loopCounter in range(4):
import turtle
Example prompt:
Generate a series of Parsons Problems designed to teach students how to draw regular polygons using loops in Python's turtle library. Each problem should:
For extra clarity, you can provide AI with an example of what you're looking for.
Additional prompt:
Example response
Parsons problems are programming puzzles where a working solution to a problem has been broken up into blocks of code and jumbled up. Students are given the mixed-up code and challenged to re-assemble the code in the correct order. Some Parsons problems, often referred to as two-dimensional Parsons problems, also require the code blocks to be indented correctly. Parsons problems can also contain extra lines of code, called distractors, which are not needed for the code to work.
Although primarily used with text-based languages, Parsons problems can also be used with block-based languages too! The idea behind parson problems is to allow students to focus on the core concepts such as flow of control, conditionals and loops, without the frustration of syntax errors.
Example of a Parsons problem with distractors:
timmy = turtle.Turtle()
window = turtle.Screen()
timmy.forward(100)
timmy.right(90)
timmy.turn(90)
For loopCounter in range(4)
for loopCounter in range(4):
import turtle
Example prompt:
Generate a series of Parsons Problems designed to teach students how to draw regular polygons using loops in Python's turtle library. Each problem should:
- Focus on one of the following shapes: square, triangle, hexagon, pentagon, octagon.
- Include all necessary lines of code, but jumbled.
- Include at least two plausible distractor lines that are not needed for the correct solution.
- Be formatted as a list of code lines (not in order), with distractors clearly mixed in.
- Avoid giving away the correct order or identifying distractors.
- Provide each problem in a separate section labelled with the shape name.
For extra clarity, you can provide AI with an example of what you're looking for.
Additional prompt:
- Here is an example of a Parsons Problem, with distractors, for drawing a regular polygon square shape using the turtle library in Python.
timmy = turtle.Turtle()
window = turtle.Screen()
timmy.forward(100)
timmy.right(90)
timmy.turn(90)
For loopCounter in range(4)
for loopCounter in range(4):
import turtle
Example response
Using AI to create lessons using PRIMM
PRIMM is a research-based approach to teaching programming. It is made up of five stages: Predict, Run, Investigate, Modify, Make. Each stage is used in planning lessons and activities to support the learning of programming.
The five stages of PRIMM are:
Example prompt:
Design a detailed lesson plan for a Python lesson, using PRIMM, where the end goal is to create a Magic 8-ball game. The lesson should be aligned with the National curriculum in England: secondary curriculum (key stage 3). Please structure the lesson into distinct segments: a 10-minute starter activity to introduce the topic, a 10-minute introduction to the topic, a 30-minute hands-on activity to reinforce learning, and a 10-minute formative assessment to gauge student understanding. Include in your plan: specific learning objectives, materials needed for each segment, strategies for student engagement, and clear assessment criteria.
PRIMM is a research-based approach to teaching programming. It is made up of five stages: Predict, Run, Investigate, Modify, Make. Each stage is used in planning lessons and activities to support the learning of programming.
The five stages of PRIMM are:
- Predict: Students are given a working program and challenged to predict what the code will do. At this level, the focus is on what the code actually does.
- Run: Students run the program so that they can test their predictions and discuss their findings with their partner or the rest of the class.
- Investigate: The teacher provides a range of scaffolded activities aimed to help the students to explore what each line of code does. Strategies can include tracing, commenting code, annotating, debugging, etc.
- Modify: Students are challenged to modify the working program in order to change its functionality in some way.
- Make: Students design a new program that is based on the given solution but which solves a new problem.
Example prompt:
Design a detailed lesson plan for a Python lesson, using PRIMM, where the end goal is to create a Magic 8-ball game. The lesson should be aligned with the National curriculum in England: secondary curriculum (key stage 3). Please structure the lesson into distinct segments: a 10-minute starter activity to introduce the topic, a 10-minute introduction to the topic, a 30-minute hands-on activity to reinforce learning, and a 10-minute formative assessment to gauge student understanding. Include in your plan: specific learning objectives, materials needed for each segment, strategies for student engagement, and clear assessment criteria.