Unplugged: Circle a Chair
In this activity, you will give someone specific instructions to do a simple action.
- Place a chair somewhere in the room
- Have either your teacher or a group member stand with their back to the back of a chair
- Have the person demonstrate the task of walking around the chair and sitting down
- Come up with instructions or pseudocode that this person needs to follow in order to get from standing behind the chair to sitting in the chair
- The person can only follow one instruction at a time so they need to be step-by–step. Examples of instructions are:
- Turn left
- Turn right
- Step forward
- Step backward
- Have the person follow your instructions/algorithm
- Did it Work? If not, try to come up with different pseudocode. Code often doesn’t work the first time
- Examine your instructions. Does anything repeat? Whenever you have code that repeats, you have an opportunity to use a loop to simplify your code.
- What lines are repeated?
- How many times are they repeated?
- So how could we rewrite this code?
- Have the person stand with their back to the chair again. This time, have them follow your revised code
There! They have just rewritten many lines of code with just a few lines of code, by using a loop.
The ‘repeat’ command creates a loop. The code within the loop gets repeated a certain number of times until a condition is met. The condition in this algorithm is that the code in the loop is repeated 4 times. Once this condition is met, the program exits the loop.
- Work in small groups to form additional examples and pseudocode.