Friday, May 27, 2016

You’re the Variable

One of my big goals this year has been to make my classes more interactive. I want to get kids involved and not be just passive listeners. Surprisingly students seem resistant to participate. They like sitting back and pretending to pay attention. That's not very good for learning though. Yesterday I tried something different. I’d like to say it was well planned and laid out in advance but it wasn’t. It sort of just happened. But it worked out well so I thought I would share it. Maybe someone can help me make it better for next year.

So hear is the set up. We have about two weeks left to the school year and I’ve been introducing my freshmen to coding. Lately we have been discussing loops.  My idea was some code that simulated a horse race multiple times while counting which horse won the most times. I decide to talk about coin flipping first.

I assigned four roles for students:

  • A student to flip coins and report heads or tails.
  • A student to count how many flips happened and call stop after the 10th flip
  • A student to keep track of heads
  • A student to keep track of tails

We ran through several iterations of students flipping coins and having my “variables” report results.

Next we wrote some code together during which I made frequent references to the initial people based “code.” We translated the various student roles into variables, actions (like flipping and counting the for loop), and let’s not forget displaying results. It seemed to work well as the level of involvement in creating the code was up from usual. We’ll see about retention today but I am hopeful. I want to find more ways to do similar things. Suggestions anyone?

1 comment:

Alex Lew said...

I do something similar when we learn GUI programming! We use a Racket framework called Universe, in which you implement an interactive program by defining a few functions and registering them as callbacks:

render —> takes in some info about application state and returns a rendered image of the app — basically the “painting” method
handle-key-press —> takes in info about current app state and a key press that just happened, returns new app state info (which will be passed along to render to re-render the scene)
handle-mouse-event —> same idea as handle-key-press

I have the kids be the functions, with render actually drawing pictures of windows on the board, and the others being “called” as apporpriate and responding with their return values. I play the ‘operating system’, and will ask the mouse handler, e.g., “OK, so the mouse was just clicked at position 40, 50. The application state is currently x,y,z. What is the new application state?” … “OK, render, the new app state is a,b,c — render that to the board."

We go through this a bit, and then sit down to write the actual code, and I name the functions after the kids. It helps give context to the code they’re writing, and gets them engaged! I definitely want to think about how to use this type of activity more.