Teaching my 12-Year-Old Daughter to Program, Part 3

Martin Luther King Day was a holiday for both my daughter’s school and my employer. The three-day weekend gave us both enough of a break that we got back to our previously-scheduled programming lessons—and this was a fun one!

(You may notice that the title of this post has a small difference from the earlier ones. Since the last post a couple weeks ago, Rosey has turned 12.)

Calling ‘puts’ over and over again is alright, but there’s nothing more fun for a fledgling programmer than asking the user a question, getting the answer, and then writing back a witty reply. In Chapter 4 of Learn to Program, Rosey learned about variables and assignment but the real fun came in Chapter 5, when she learned how to call gets to get a string from the user and then use the String.+ method to write back that string in the middle of a response.

Near the beginning of the chapter, though, I decided to take a detour and explain computer memory. This is the sentence in the book that triggered this:

“To store the string in your computer’s memory for user later in your program….”

The words “store the string in memory” reminded me of something I can still clearly remember: way back when I was 14 or so and first learning to use WordStar on my family’s Osborne 1, I found it hard to understand the difference between “Open” and “Save.” The picture in my mind of what’s going on inside the computer was extremely vague. I didn’t understand the difference between RAM and the Hard Drive, and why the word Open should mean moving something from the hard drive to RAM and Save should mean moving something from RAM to the hard drive.

I’m a believer in remembering what I struggled with in a subject, and trying to explain those things when I teach the subject. I hope that makes me a better teacher.

Computer Memory

RAM vs. HD, Open vs. Save...and the BRAIN

So I quickly sketched the attached diagram, explaining the pieces as I went. As I suspected, the difference between RAM and HD was pretty abstract for her and took some time even though she is an experienced game player. She got it, though, and we moved on the fun stuff.

The chapter on variables and assignment was surprisingly easy. The first few pages of the next chapter (Chapter 5, “Mixing it Up”) were useful for her as well, although not incredibly exciting. They explained things like why you can’t do ‘5’ + 5, and why ‘99.999’.to_i returns 999.

But this was all just leading up to the awesome part. In section 5.3 the book introduces the gets function, and in 5.5 you ask the user’s name and then print it back in a sentence. Rosey was so excited the first time she ran that. It was fun to watch.

Finally she did the exercises for the chapter, which were really kid-friendly. The first one tells you to write a program that asks for a person’s first, middle, and last names and then greets the person using their full name. She had fun with that, writing out prompts like “That’s an…um, interesting middle name.” And the next exercise was cute: ask for a person’s favorite number, add one to it, and tactfully suggest that as a better favorite number because it’s bigger. She got the essence of the program right on the first try but she was missing the conversion between strings and numbers. I made sure not to point out the errors as she was typing. I think that was the right approach, because the interruptions might have prevented her from getting the basic logic down right.

One last thing to note: I remember being confused about the assignment operator when I learned to program, and she was too. In particular, she thought the value should go on the left and the assigned variable should go on the right:


fav_number + 1 = new_fav

Take the programmer part out of your brain and read that code out loud. It makes sense, doesn’t it?

“Favorite number plus one equals the new favorite number.”

But alas, the computer doesn’t think so. She grudgingly accepted that and moved on.

I’m not sure when our next lesson will be. Hopefully sooner than the next holiday, since that’s in May. 🙂

See you all next time….

Leave a Reply

Your email address will not be published. Required fields are marked *

Feel free to use <a>, <b>, <i>, <strong>, <em>, <strike>, <code>.

Code blocks:
[code language="ruby/javascript/html/css/sass/bash"]
[/code]