## Want to keep learning?

This content is taken from the Raspberry Pi Foundation & National Centre for Computing Education's online course, Programming Pedagogy in Secondary Schools: Inspiring Computing Teaching. Join the course to learn more.
2.5

## Raspberry Pi Foundation

Skip to 0 minutes and 3 seconds A Parsons problem is a task that involves giving learners all of the lines of code required to solve a problem. The difference is that the lines have been jumbled up so they’re no longer in the correct order. Learners are required to place the lines of code into the correct order to form a working segment of code. The main benefit of a Parsons problem is that learners focus on the code structure rather than the syntax. The process lowers the content load, allowing the learners to practise sequencing and the meaning of the code.

Skip to 0 minutes and 28 seconds Particularly in the early stages of learning to program, this saves time for the learner, rather than spending hours writing out code and making common mistakes, such as indentation errors, missing brackets, commas, and columns. Here’s an example of three lines of code that will cause errors if kept in that order. Can you rearrange them to make a working program?

Skip to 0 minutes and 47 seconds You can add extra layers of complexity to your Parsons problem by removing any indentation in Python, which need to be reinserted at the right place, or include the structures of incorrect lines of code. The structures can also highlight common misconceptions, but there is a risk that the structures can increase the cognitive load to the learner and reduce their chance of success. As well as this, there is a danger that the structures can lead to the learner committing the error to the long term memory. So use them wisely. When writing Parsons problems, avoid providing letters next to each line of code, requiring that to place a letter and not the lines of code in order.

Skip to 1 minute and 21 seconds This can lead to an increase in cognitive load, as learners can easily forget which letter refers to which line of code. Instead, provide space for the learner to write the lines of code, and make sure that is a unique answer for each question. There should only be one combination of ordering the lines that should lead to a correct solution. At which point during the learning journey do you think using Parsons problems might be most effective? Do you have examples of Parsons problems using your lessons? Share your thoughts and experiences in the comment section.

# Parson's Problems

A Parson’s Problem is a task that involves giving learners all of the lines of code required to solve a problem, but with the lines jumbled so that they are not in the correct order. Learners are required to place the lines into the correct order to form a working code segment.

The main benefit of Parson’s Problems is that the learner is focusing on code structure rather than syntax. The process lowers the cognitive load, allowing learners to practise sequencing and the meaning of the code. Particularly in the early stages of learning to program, this saves time for the learner as they don’t need to spend hours writing out code and making common mistakes such as missed brackets, commas, and colons.

The example below shows three lines of code that would cause errors if kept in this order. The task is to rearrange the lines to make a working program.

Have a go at this yourself!


print(food + " is a good choice ")
food = input("What is your favourite food? " + name+”?”)



The code above wouldn’t work because variables are being used before they have been declared. It is the job of the learner to put these lines of code into the correct order to make a working program.

Extra layers of complexity can be added to make Parson’s Problems more suitable to the increasing ability of the learners. For example, when teaching concepts such as selection and loops in Python, indentation is important. These are known as a 2D Parson’s Problem. You could begin with scaffolding the indentation for the learners by using a block-based editor such as Scratch or EduBlocks in which the learners have to connect the blocks together but the indention is already provided. An example of this can be found here: Scratch Parson’s Problem.

Presenting this problem in Python (see the example below) presents an extra layer of complexity, as the learners are required not only to order the code, but also to indent at the appropriate places.

Some examples of Parson’s Problems include distractors. These are incorrect lines or blocks of code that are included in the library of code that the learners can use to solve the problem.


price = 3.50
quantity = 5
total = price * Quantity
total = price * quantity
print(total)
print(“total”)



Adding distractors adds an extra layer of difficulty to Parson’s Problems, and like well-written multiple-choice questions, they can help to highlight common misconceptions. There is evidence from Harms et al. suggesting that adding distractors can unnecessarily increase the cognitive load to the learner, reducing the chance of success and increasing the amount of time learners spend on the task. There is also a danger that distractors can lead to the learner committing the error to their long-term memory. Use them wisely.

### What are the benefits of Parson’s Problems?

Other than the main benefit outlined above, Parson’s Problems expose the learner to logic and syntax that they may not be fully familiar with.

Denny et al. “make a case that marks from a Parson’s Problem make clear what students don’t know (specifically in both syntax and logic)”. They can allow for an easier analysis of the common errors that learners make. “The open-ended nature of code writing questions makes identifying errors difficult” — but we can be sure when using a Parson’s Problem that the error wasn’t because of a typo.

Code tracing (the process of learners reading code and identifying what it does or would output as) is considered to fall into the lower categories of Bloom’s taxonomy, whereas code writing is considered a higher-order skill. Parson’s problems require the learners to organise, examine, and experiment with pre-existing coding structures, all of which are the upper middle skills within the taxonomy.

### Advice for writing Parson’s Problems

Avoid providing the learners with letters next to each line of code, requiring them to simply place the letters and not the lines of code in order. This can lead to an increase in cognitive load as learners can easily forget what each letter refers to.

The following is an example of how NOT to present a Parson’s Problem to learners.

Place the letters in the correct order
A - print(computer_Choice) B
B - from random import randint C
C - rpsChoices = [“Rock”,”Paper”,”Scissors”] D
D - computer_Choices = rpsChoices[randint(0,2)] A

The question above would be better if there were space for the learners to write the lines of code:

Place lines of code in the correct order to form a working problem
print(computer_Choice) from random import randint
from random import randint rpsChoices = [“Rock”,”Paper”,”Scissors”]
rpsChoices = [“Rock”,”Paper”,”Scissors”] computer_Choices = rpsChoices[randint(0,2)]
computer_Choices = rpsChoices[randint(0,2)] print(computer_Choice)

Denny et al. recommend making sure that there is a unique answer for each question; that is, there should be only one combination of the ordering of the lines that would lead to a correct solution.

In theory, it is possible for learners to correctly guess the answer to a simple Parson’s Problem without fully understanding the construct or the logic being tested. Asking more than one question that tests the same logic or construct can be helpful.

### Discuss

• At which point during the learning journey do you think using Parson’s Problems would be most effective?
• Share an example of a good Parson’s Problem if you have one.