Functional Keychains
Sometimes you want to do certain instructions over and over again. That’s where functions come in handy! Group all repeated instructions into one place, give them a simple name, then you can call that entire group at the same time just by using the name you gave it.
In this activity, you’ll make a keychain out of string, beads and a special charm. To do this, you’ll follow a series a repetitive steps and then identify certain sets of “skills” that are duplicated several times. Later, you can attach your keychain to your backpack or to a set of keys.
Steps to make the keychain:
1. Put a bead on the string, then tie a knot. Put another bead on a string, and tie another knot. Then, put a spacer on the string, then tie a knot. After that, do those steps again: Bead, knot, bead, knot, spacer, knot. Finally, add on the special charm and tie one last knot.
2. This routine takes quite a few steps, so it may help to sing or rap the steps with your team to remember the order.
-
-
- “Bead, knot, bead, knot, spacer, knot.
-
-
-
- Bead, knot, bead, knot, spacer, knot.
-
-
-
- Special charm, final knot.”
-
3. Write one instruction per line in the “Program” area using a pencil. You’ll notice quickly, though, that you have more steps than lines available.
4. Did you notice anywhere in your program with several sets of identical instructions? Move one or more of these sets into the “Skills” areas below; this is a function.
5. Rewrite the original program, using the skill names instead of actually writing out the group of instructions that the skills describe. By the way, there are several ways to write the program. Share your new program with your team and hear the many solutions your team has written.