Coding Strategies: Using AI to support the teaching of coding
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.
Using AI to create worked examples
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.
Example
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.
Example
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:
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 types 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 types 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:
A faded worked example is a teaching technique used in coding education. It involves providing students with a nearly completed block of code and asking them to fill in some blanks. Over time, the number of blanks increases until the student is essentially coding the entire problem on their own. Create a series of faded worked examples for drawing the following regular polygon shapes using the turtle library in Python: Square, Triangle, Pentagon, Hexagon.
Example response:
Prompt:
A faded worked example is a teaching technique used in coding education. It involves providing students with a nearly completed block of code and asking them to fill in some blanks. Over time, the number of blanks increases until the student is essentially coding the entire problem on their own. Create a series of faded worked examples for drawing the following regular polygon shapes using the turtle library in Python: Square, Triangle, Pentagon, Hexagon.
Example response:
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 reassemble the code in the correct order. Parsons problems can also contain extra lines of code, called distractors, which are not needed for the code to work.
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
As with a worked examples, I find that AI works best if provided with a description and example first.
Example prompt:
Prompt 1:
Prompt 2:
Prompt 3:
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 reassemble the code in the correct order. Parsons problems can also contain extra lines of code, called distractors, which are not needed for the code to work.
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
As with a worked examples, I find that AI works best if provided with a description and example first.
Example prompt:
Prompt 1:
- A Parsons Problem is an exercise used to teach coding. In a Parsons Problem, students are given all the lines of code needed to complete a task, but the lines are jumbled. Their task is to arrange these lines in the correct order to form a working program. Parsons problems can also contain extra lines of code, called distractors, which are not needed for the code to work.
Prompt 2:
- 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
Prompt 3:
- Create a series of Parsons Problems for drawing regular polygon shapes using the turtle library in Python with at least two plausible distractors.
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:
Prompt 1:
Prompt 2:
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:
Prompt 1:
- PRIMM is an educational approach used to structure programming lessons in computing. It stands for Predict, Run, Investigate, Modify, and Make. Each stage represents a different part of the learning process:
- Predict: Students predict what a given piece of code will do.
- Run: They run the code to see if their predictions were correct.
- Investigate: Students explore the code to understand how it works.
- Modify: They make changes to the code to alter its functionality.
- Make: Finally, students create their own programs using the concepts they've learned.
Prompt 2:
- 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.