Thursday, October 9, 2014

Computer Science Day 5 - Graph Paper Programming!

Oh boy, we're so close to sitting in front of computers and coding I can almost taste it!

Today was day 5 of our computer science work. So far, we've explored how computer scientists work, learned how binary numbers work, seen how binary codes can be used to store letter data, and finally how binary numbers can store images using a compression technique. Pretty much all of these lessons have been pulled from CS Unplugged, a fantastic resource with a much more comprehensive scope. However, I think I'd start to lose the kids if we went through the entire CS Unplugged curriculum, as there's a lot of dense technical information packed into some of those lessons.

Instead, we started today by pulling a lesson from's K-8 Intro to Computer Science course: Graph Paper Programming. Truthfully, they've updated the lesson and included it in their new courses for K-5, but I just re-used the lesson I did last year with fifth and sixth grade students, since it worked great as-is.

We began the day by correcting our homework from last session. Students had to draw some images given compression codes, then make their own picture and write its code next to a blank grid. The students had a blast giving their codes to classmates and discovering what their peers had drawn! There were plenty of students whose pictures did not match up, and they immediately began investigating where the error was made. Was it the artist's fault, and there was an error in the code? Or was it the coder who did not follow instructions correctly?

Once they were done reviewing homework, we went into today's lesson. I defined two new terms: algorithm and program. We talked about how they've seen algorithms in other parts of their lives: cooking from recipes, putting together furniture, following science experiments, etc.

We then looked at how an algorithm can be made into a program if the instructions used can be understood by a computer. I passed out their programming keys and projected a simple 5x5 checkerboard pattern. I talked through the basic algorithm first, using general terms like, "Move over two spaces and then shade a square" and, "Move down and all the way back to the left."

The next step was to translate that algorithm into commands from our programming keys. I went through and created a program with a lot of "unnecessary" steps. For instance, I only ever shaded from left to right, so at the end of each line, I went down a row and all the way back to the left before going back over the line and shading what was necessary. I emphasized to students that, when you're just getting started, it's okay to use some extra commands just to make the picture! You can always go back over your work later and seek ways of condensing steps and optimizing programs.

That being said, we talked together about how to simplify my program and use fewer steps. Students very quickly found that I could zig-zag through the picture, shading squares as I went, and would cut down on 9 commands. We did that, and talked about how it could mess with your mind sometimes, writing code from left to right that progressed through the grid from right to left! This was confusing to many students; they wanted to write their code in exactly the same way they would progress through the puzzle! To help make sure our code was correct, we practiced keeping on finger on the grid to track which square we were in, and moving very slowly and deliberately.

Next, students numbered off from 1 to 6 and did one of the puzzles on a half-sheet I passed out. When finished, they found someone else who did the same puzzle and compared their programs, looking for bugs and ways to optimize their code.

Their final assignment was to make their own picture on a 7x7 grid, and to write the program for their picture on a separate piece of paper. In most classes, I also showed them how to make colorful pictures by defining colors (ex: color 1 = blue, color 2 = red) and using the "switch to next color" command. Next time, they'll give someone else their program for them to create the picture.

Then, we'll hop on and start their first set of puzzles!

I can't wait! In two classes, I'll be doing that this coming Monday; in two other classes, I have to wait until Friday... :-(

In the meantime, though, I'm expanding my work to also head into some sixth grade classes. My key task right now is to revise day 1's lesson to be less of a snooze-fest...Any ideas?
Post a Comment