Sunday, August 31, 2014

Triangles (programming lesson 3)

Who: Baan Pathomtham 5th grade class (all present)
Where: at school
When: 2 hours Monday morning


Again, starting with some code that the kids wrote:
A golden star for their first for loop

More complex 3 levels of nested for loops

What your child has learned

This is just a quick list; you can ask them to show you and, if anything seems unclear, I've got some links that can help or just send me a Line message.

0. Reminder: You can see code that the students are writing through this directory. My own folder with a lot of examples is here: and the class folder is here

1. Basics of for loops: this is a way they can run commands repeatedly without having to write repeated lines of code. There are some spacing and punctuation issues to get this right, so encourage them to use the blocks to get things lined up correctly.

2. How to use the command line to run single lines of code. Easier for them to show you than for me to explain it.  This is something they can use to test an idea or in debugging.

3. How do direct a named object. Using this program, they got to test their knowledge of the command line and movement commands by shifting around the named triangles:

Remember this reference:


This week, the challenge is to draw their name in Thai and English.  These links are really useful if they need help understanding the turning and arc commands lt (left turn) and rt (right turn)

Please look through these with your children.

Here is a version of my name in Thai:

Some great things they did
I'm going to start flagging things the students showed in class that are really good and we should encourage.
For loops: when asked to match code with output, Win made some good observations that helped him form a hypothesis without tracing through every line of the code.  In the golden star code, he saw that the for loop would run 5 iterations, so he was looking for a picture where 5 was a prominent feature. In addition, he saw that the pen was going to be gold, so he could match up the color to add confidence to his prediction. Over time, as they encounter more complex code, they will need to use features like this to get a sense of the program, even if there are commands they don't understand.

At the end of the class, Kan started showing programs his brother had written.  Really fantastic to see that Kan enjoyed what we were doing enough to share with his family, that he had learned enough to help get someone started.  This also got the whole class excited about exploring code written by other users. We want to encourage them to learn from other examples they see, which means:
  • searching for examples
  • thinking about what other programs do
  • testing them
  • changing them and seeing the effect

What I learned
Make the tasks concrete and explicit, at least for one example, before letting them pursue a more general/less structured investigation.

Have a back-up for when the network is down.


  1. Next week:
    (1) present their names and talk about how they wrote it: what was hard, what was easy, what they want to improve, what they are really pleased to have created
    (2) show them: Alphabet typwriter
    (2) more for loops, specifically pictures, the code used to generate them, but sectiones of code missing (either lines or individual variables).
    (3) homework: create a garden or forest (using for loops and drawing commands)

  2. Additional notes for the next class, expanding 2' (the second 2!):
    for 3 nested loop of colored polygons, what difference does it make where the fd 40 statement goes?
    Explore this

    Change the max # of sides and see if you can correct the code to create a rectangular grid.

    Homework alternative: make mega's gear into a shorter program using for loops.