Build a Parsons problem
Give students the lines of a program and have them put the lines in order and indent them.
What students should learn
Students can see how a working program fits together: set up a variable, repeat the work, then print after the loop.
Use a program students have already seen, with four real lines and one believable wrong line. The example below adds 1, 2, and 3, then prints 6.
Try the block
A teaching sequence
- Take typing out of it. Give total = 0, the loop header, total += n, and print(total) as separate lines. Students put them in order, then explain the result.
- Make indentation part of the task. Turn on indentation in the Ordering block. In the solution, total += n is inside the loop and print(total) is outside it. Ask what changes if print moves inside.
- Add one wrong line. Add total = n as an extra line that doesn’t belong. Ask students why it gives a different result than total += n. Skip distractors that are just typos.
What to assess
Save the correct order and indentation as the solution, then preview it as a student. Try a correct answer, a misplaced print, and the wrong line to make sure each is graded the way you expect. Add a short explanation question if you want to know why students chose that order.
A follow-up task
Next, take away the lines and ask students to write a similar program. If a student has trouble dragging, agree on another way for them to give the ordered, indented answer before you grade it.