Friday, June 8, 2012

30 min - Fun with Functions (K-12)

Use posters to represent functions

This segment is intended to show one of the many benefits of using functions, namely how much easier it can be to use functions for repetitive tasks.  Students will follow an algorithm to make a chain for their backpacks, utilizing no fewer than two functions along the way.

Kindergarten through 2nd modification: Young children sometimes have a problem tying knots, so we modify this exercise into making bookmarks with stickers.

Note:  We have discovered that students as old as 8th grade are having a difficult time tying knots.  If you are in doubt as to whether your class has that ability, please take a moment to test their skills by having them tie some string around a pencil.  If more than a quarter of the class is unable to do this without help or demonstration, this lesson may take 50 minutes rather than the original 30.

3 large sheets of paper, sectioned off for 8.5x5.5 rectangles or
1 printout for document camera

4 each of 8.5x5.5 K-2 symbol sheets or 3-12 symbol sheets

Kindergarten through 2 -
1.5" x 8.5" strips of cardstock/chipboard (1/student)
1" glue-on or sticky-back squares in black and white (8 b&w/student)
    * You can use strips of contact paper, or
        simply have kids glue squares of construction
        paper to their bookmarks.

Third through Twelfth -
Cording (1yd/student)
Pony beads or Hex Nuts (4/student)
Jewelry Rings or washers (4/student)

K through 12 adaption* -
Pipe Cleaners folded around rubberbands (1/student)
Pony beads or Hex Nuts (4/student)
Jewelry Rings or washers (2/student)
Fancy Buttons (1/student - Optional)


As the instructor, you will begin by thanking the class for letting you come visit. It is very important that the instructor be pleasant and up-beat.

I like to hand out supplies for this exercise in advance.  That way, the kids can make the connection between the images that they see on the screen (board) and the items that they'll be using.  For kindergartners, supply timing is highly dependent on the nature of the classroom.

Place the three over-sized sheets of paper on the board.  If you have a document projector, you can use this alternate layout.

Explain that the center area is where we put the "directions" for the "program" that we'll be following (when working with the lower grades, you can pretend y'all have been turned to robots).  Tell them that at the end of the lesson, you will all be following these directions -- called an "algorithm" -- to make your craft.

Give them this scenario:
"We are all going to be machines who make these expertly-crafted bookmarks (or zipper-pulls).  But since machines don't think on their own (yet) the robot director must first spell out their instructions in the language that they understand.  For us, that language will be these symbols:"

Symbols from kthru2symbols.pdf 
Symbols from 3thru12symbols.pdf 
"As robots, we will do what is on this 'program' grid and see what we come up with! To start, we want to put glue on the top of our bookmark, lay down a black square, then move down to the next section. That would look like this:"

1) Glue 2) Black square 3) Down

"But what if we wanted to do: glue, black square, move down, glue, white square, move down? We'll have to add more symbols:"

1) Glue 2) Black square 3) Down
3) Glue 4) White square 3) Down

"And what if you want to do:
glue, black square, down, glue, white square, down, glue, black square, down, glue, white square, down? We don't have enough slots for that!!! And we need to do the 'glue, black square, down, glue, white square, down' sequence FOUR times to finish our bookmark."

At this point someone might remind you that you have two more pieces of paper...labeled f1 and f2. If they don't, you can pretend to discover it yourself. Tell the students that these pieces of paper are special. They are called "functions" and they allow you to save a complicated or repeating sequence all in one place, so that you can call them later simply by using the function's name as a symbol.

Ask the students if they see any steps in your program that repeat. They may point out the entire "glue, black square, down, glue, white square, down" sequence. If that's the case, go ahead and start with all of it in f1 and ask them what they should put in the program to let the robots know that they have to look in f1 for the sequence of bookmark making. Once they understand that (or if they go straight to saying f1=glue, black square, down and f2=glue, white square, down) you can separate the sections into the two different functions and ask them how to get the ideas across to the robots *now*.

Walk through the program with them a few times. Tell them that you will be the "program counter", pointing to where you are. Each time you reach a slot in the program that has a function name (f1 or f2) in it, hop over to that function's piece of paper and go through the steps listed on it, calling the symbols out as you touch them. Once the entire class is chanting with you, it's time to actually make your bookmarks together, while following the patterns.

The above scenario was obviously for the lower grade level, but the majority of it stays the same for the older students, just replaced by "tie, tie, bead" and "tie, tie, hoop". If your older students are getting the ideas rather quickly, you may have time to mix things up by placing an f2 call inside f1 at the end. They should see that this automatically calls f2 when f1 has finished.

What happens when instead of calling f2 inside of f1, you call f1 inside of f1?!?! That's called "recursion"...which comes from the word "recur" which means "to happen again". So calling the function inside of itself makes it happen again, then that call makes it happen again, which makes it happen again! Recursion could be dangerous!

Act as the program counter one last time while you walk the class through each of the steps to finish their zipper-pulls (or bookmarks). Congratulate the children as they finish their crafts and let them know that they just learned one of the most handy things in computer programming! Functions!

* I recently found a solution for those who have difficulty tying.  

Before the lesson, I fold a pipecleaner around a rubberband for each student.  

From that point, they only need to slide the beads up one side of the wire and twist to keep them on.  

Space is limited, so we only use one hoop per cycle.  

At the end, we add a button (the kind with the loop on the back) and roll the end up like a little snail to keep the wires from getting pokey.

No comments:

Post a Comment