How high school students start thinking about code

July 5, 2009 at 10:45 pm 16 comments

My colleague Amy Bruckman and her student Betsy diSalvo have a really great project going on this summer, called Glitch.  Betsy is interested in how African-American males engage with technology and why so few pursue computing as a career.  She notes that African-American males play video games more than any other gender-ethnicity demographic groups, and yet are one of the most under-represented groups in computing majors and careers.  To address this discrepancy, Betsy and Amy are training a group of African-American teen age boys to be game testers, and in so doing, getting them to engage with how the games they love are built.

Amy and Betsy are teamed up with Dr. Charles Meadows of Morehouse College, who is teaching the teenagers how to program in Alice.  Betsy wanted them to see some textual code, too, to get them to see how programs like their games are created.  I agreed to teach a few sessions of Alice + Media Computation (like at the Tea Party site) being developed by Barb Ericson, Wanda Dann, and Steve Cooper.  That way, they’d be learning a bit of textual code to work with their Alice worlds.  I decided to do it with Python, so that there’d be less overhead than Java.  (My slides are available, if you’re interested.)

I’ve found it fascinating to work with the Glitch guys.  It’s been many years since I’ve taught high school students, and rarely in a situation with a small number of students.  I get the chance to see what they’re struggling with, and how they tackle problems.  I’m learning a lot about how these students think about code.

They got the idea early on that they can change constants in programs, and things generally keep working, though sometimes in new ways.  One of the students took our function to generate a negative of an image and started changing constants, like this:

def negative(picture):
  for p in getPixels(picture):
    r = getRed(p)
    b = getBlue(p)
    g = getGreen(p)
    #Original: color = makeColor(255-r, 255-g, 255-b)
    color = makeColor(20-r, 5-g, 100-b)
    setColor(p,color)

The result was really interesting. Because the values for red, green, and blue were clamped at 0, the effect was to posterize the image.  Bright colors emerged, and the number of colors were reduced.  I don’t think the student who invented this really understood what he was doing.  It was a positive outcome that rewarded tinkering, poking-around.

Another one of the students wanted to write a function to make an image completely black.  What he wrote was absolutely amazing to me.

def makeBlack(picture):
  for p in getPixels(picture):
    r = getRed(p)
    b = getBlue(p)
    g = getGreen(p)
    #Original: color = makeColor(255-r, 255-g, 255-b)
    color = makeColor(0=r, 0=g, 0=b)
    setColor(p,color)

I asked him to explain what he was doing.  Here’s how I think he understood his program.  He saw the variables r, g, and b as defining a relationship — that r would represent the red channel for the pixel, so changing r would change the pixel’s red value.  He saw 0=r as setting the red value to zero.  Why didn’t he write “r=0“?  He hadn’t quite internalized left-hand side vs. right-hand side.  He completely understood that he needed to make a color with red, green, and blue all zero, and he could explain clearly what he wanted his program to do. He just didn’t understand why his program didn’t work.  I find it amazing that he had such a clear view of what he wanted and how his program should work.

As a group, I asked them to try to figure out what the right “brightness” value should be, in order to make a grayscale function.  Here’s what we started with:

def grayscale(picture):
  for p in getPixels(picture):
    r = getRed(p)
    b = getBlue(p)
    g = getGreen(p)
    brightness = ???
    color = makeColor(brightness,brightness,brightness)
    setColor(p,color)

The question is, what goes in the place of “???”  Somebody guessed “50” and the others shot him down.  That would fill the whole image with the same gray value.  They guessed “r” (the red channel value) and we tried that — you get a good grayscale, but too light.  Then we tried “b” (the blue channel), and it generates a good-but-dark grayscale.  One of the students correctly said, “We want the average of the color parts!”  So I replaced the right hand side with (r + g + b)/3, and the students started groaning.  “You can do that?!?”  Now, I had told them that the right hand side of the equals sign could be any expression, and I had shown them various expressions.  What was clear that they hadn’t made the connection that the right hand side of the “brightness” computation could be an expression involving red, green, and blue.

I had lunch once with Randy Pausch, the year that SIGCSE was in St. Louis.  He told me, “Variables are easy! You should never have to spend more than 10 minutes on them!”  I think he was telling the truth as he saw it — for Carnegie-Mellon University students.  Most students that I see as non-CS major freshmen at Georgia Tech, and these high school students, find variables and expressions to have a lot more facets and complexities than I might have guessed.  These examples are just pieces of the interesting ways in which they think of variables.  If we want to help students to learn to code, we have to spend time to make sure that they get these basic ideas like variables, which to us are “easy,” but aren’t when one is first getting started.

Entry filed under: Uncategorized. Tags: , , , , .

Looking for Excuses to Do Something Good Aligning Computer Science with Mathematics by Felleisen and Krishnamurthi

16 Comments Add your own

  • 1. derChef  |  July 6, 2009 at 2:12 am

    I hope I’m wrong, but I’m getting a condescending racist vibe from this article. Why are you using Python for “less overhead?” Because you think black students are inherently less likely to be able to grasp Java, C#, C++, etc?

    There’s also the recurring theme of “let’s see how they think” “wow, they have some cognitive function and seem to be able to learn and understand”.

    You sound like cultural anthropologists marveling at how well some lost tribe can interact with you.

    Reply
    • 2. Mark Guzdial  |  July 6, 2009 at 2:17 am

      We’ve been teaching Python and Java using Media Computation for 7 years now. We use Python in all our summer camps with high school and middle school students, regardless of race and gender. Python is easier to get started with.

      I’m a computing education researcher. I look at how all students understand code. It helps me to understand how to teach it better, and how programming might change to better fit students’ understanding.

      Reply
    • 3. xerxesb  |  July 6, 2009 at 3:10 am

      @derChef: That has to be the most ridiculous aspersion i’ve read in a long time – it’s irrational aggressiveness like yours which fuels racist mentalities.

      Believe it or not, the world does not all think in terms of skin colour, so seriously get over yourself and admire the article for its content rather than spreading your agenda driven diatribe.

      -Xerxes

      Reply
    • 4. Naproxen  |  July 6, 2009 at 4:25 am

      You’re kidding me right?

      First off, Python is a great language, one that I use frequently precisely because it has less overhead and is easy to understand. I am a professional software engineer with a CS degree. It has good abstraction and allows you to express your ideas concisely without having to deal with the mundane details. It is also a popular language at Google as well. Teaching people to think more abstractly is in no way condescending.

      Second, did you not read the introduction? Yes the article deals with race or at least a segment of our population that is under represented in the software industry. I know because I’ve worked in it for years and wondered about this trend myself as well. How a person thinks is not only genetic but also a result of how he or she is raised. In fact I would wager the color of one’s skin or his physical features has zero influence on his cognitive processes compared to his social and cultural upbringing. Perhaps there are cultural or societal influences at work that is causing the absence of this specific segment of our population from the software industry. Do they think differently than another group? For example, in the book Sway, Brafman cites a study in which Machiguenga tribe has a different concept of fairness under some scenarios than what Americans have. Until we understand their thinking process, it would always seem strange to us that they keep splitting the spoil 80/20 and the other participants keep accepting it.

      We can pretend that racial disparity or disparity between segments of our population does not exist by pretending that there is no such grouping. However, I doubt that will help that segment of our population. Yes race is often a silly way to group people but there are often social, economic, and cultural factors tied to sick color or physical features either because of our prejudice and/or history.

      Reply
    • 5. simeon  |  July 6, 2009 at 4:38 am

      Geez. The observation that Python “has less overhead” is a commonly cited factor in using Python as a teaching language (or as a production language for that matter). And as a someone who has also taught CS to High School students I think the discussion of novice’s though processes (I can remember being surprised at how much labor it took to grasp the concept of variables and assignment) seems entirely appropriate to me. I think you need to turn down the gain on your racism detector a bit…

      Reply
    • 6. zonkeringeneva  |  July 6, 2009 at 3:15 pm

      I hope that derChef is kidding. There is nothing condescending about this article. Unless you are wearing rose-colored glasses which see everything in such a light.

      It appears that the project was designed to “see how African-American males engage with technology and why so few pursue computing as a career.” Seems reasonable and not at all condescending.

      Being a programmer, I can really understand the whole “how they think” sentiment. I understand constants, variables and can read a block of code and figure out what it’s doing and how and why.

      Students have no such background, so it’s really interesting to see how they think. Sometimes I feel that if I had a window into their brain, I could see the connections being made.

      I think this is a great article with no hint of condescension.

      Reply
  • 7. Jake Rocheleau  |  July 6, 2009 at 3:37 am

    This is a very interesting article. I had studied PHP in High School for a little bit, and this was definitely an interesting read having just graduated this year.

    Reply
  • 8. cak  |  July 6, 2009 at 3:43 am

    To the joker who sees rascism in this, this is how all students think about these problems, no matter what race they are. Congratulations on reading too much into it, and missing the point.

    It is good to see how students think about the things we teach them. I found, during my short stint teaching, it was a common theme for students not to put two and two together. So you teach them two seperate processes, they won’t put them together unless you explicitly tell them to.

    Reply
  • 9. Lucky  |  July 6, 2009 at 9:11 am

    Great work Mark !!!

    Reply
  • 10. Rohit Arondekar  |  July 6, 2009 at 9:14 am

    def grayscale(picture):
      for p in getPixels(picture):
        r = getRed(p)
        b = getBlue(p)
        g = getGreen(p)
        brightness = ???
        color = makeColor(brightness,brightness,brightness)
        setColor(p,color)
    

    Maybe if the students knew that
    brightness = 0.3*r + 0.59*g + 0.11*b
    (which can even be found on Wikipedia)
    then they would ask the question – “How do I feed an expression in place of the ‘???’ ?” And that’s how you lead to asking questions on using variables in expressions.

    Before implementing anything – you first have to understand how to solve the problem and translate this solution/algorithm into a programming language using the constructs available. Maybe if the students had been given better exposure to the theory behind those functions maybe they would find it easier to implement them ?

    Reply
    • 11. Mark Guzdial  |  July 6, 2009 at 10:52 am

      We’re focusing on a “cookbook” style here. We certainly do explain those values (which are the NTSC’s values, used in computing luminance for television broadcast) in the full course (http://www.mediacomputation.org). We are aiming for something different in a summer camp.

      Reply
  • 12. marcampbellja  |  July 6, 2009 at 9:16 am

    Whether is it through research or gaming, anything to to stimulate young minds to achieve their full potential has my support. Keep up the good work. I wish summer programmes like yours were available to my 14 year old son.
    While we will not forget the chains, we need to shed them.

    Reply
  • 13. Paul  |  July 6, 2009 at 2:53 pm

    Everyone should learn some code. This was interesting to read about. Glad to see that younger kids are learning to master more important life tools.

    Reply
  • 14. dredful  |  July 6, 2009 at 5:09 pm

    While this is listed as an article about kids learning I find it a more interesting lesson about teaching. Given that this particular class obviously has no pre-requisite, one should not assume that all or any students in the lesson would have grasp the expected approach no matter how easy a concept might seem.

    I had experienced this in my college days helping a neighbor with an introductory programming class. The art student I was helping was very smart, but I began to realize how they really were not grasping the concepts of a step by step algorithm. They found the whole thing very frustrating. Like this instructor, I would find it fascinating at times about how this person viewed solving the problem at hand. (sometimes i wondered if it was not better than conventional wisdom)

    I had a teacher give me advice about teaching beginners in any subject that I try to always keep in mind: Everyone in this class has arrived by different path that has brought them here. Therefore, try not to assume anything about what they do or do not know.

    Reply
  • 15. mjl  |  July 7, 2009 at 2:59 am

    One more for “derChef”

    The problem Mark alluded to of seeing r, g, and b representing a relationship was exactly the problem I had some 40 years ago when I first encountered programming in a summer job. I was a mathematics major, so the notion that ‘=’ represented some sort of internal change of state was foreign – I thought that if I set up “equations” and changed one of the values then the others would change to ensure the “equations” remained solved. Believe it or not, assignment can be a very subtle concept to master – fortunately, I did master it and have been in the computing biz (as practitioner and educator) ever since.

    Oh – and I’m of German, French, and Irish stock with blue eyes and blonde hair. When I finally understood what assignment meant (after some mentoring by more senior programmers) I felt elated, not patronized. Perhaps the same is true of the young people Mark is working with.

    Reply
  • 16. troels  |  July 7, 2009 at 5:24 pm

    Most students that I see as non-CS major freshmen at Georgia Tech, and these high school students, find variables and expressions to have a lot more facets and complexities than I might have guessed.

    Certainly. The concept of variables is extremely unintuitive and abstract. Even seasoned programmers often have trouble distinguishing between variables and the values that they represent.

    Reply

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Trackback this post  |  Subscribe to the comments via RSS Feed


Enter your email address to follow this blog and receive notifications of new posts by email.

Join 11.4K other subscribers

Feeds

Recent Posts

Blog Stats

  • 2,096,531 hits
July 2009
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

CS Teaching Tips