Monday, November 24, 2014

Nested Loops Review (Programming Class 10)

who: Baan Pathomtham Grade 5
when: Monday morning
where: at school

Reviewing last week assignment

Last week, students were asked to draw this shape using double for loops if possible.  Only 1 in 4 students managed to use double for loops but none of them see this as drawing a triangle 3 times.


Nested for loops revisit

Using the homework as a starting point, I simplified the task by having them imagine the triangle to be just a line.  After they wrote the simplified program, I asked them to change the line into a triangle.  Eventually, we made our program to take any number of petals.

    num_petals = 3
    speed 10
    pen blueviolet
    for [1..num_petals]
      for [1..3]
        fd 50
        rt 120
      rt 360/num_petals

The next task is to get the students to understand how the use the counter in the for loops and the importance of placement of commands and indentation inside the for loops.  I actually had them do a simplified program before we get to the one below which creates 3 rows of colored dots (I first asked for one row of all the colored dots.)  Even these few lines of codes, it's still useful to breakdown the task into smaller, more simplified programs to learn the concepts.

    rt 90
    for x in [blue,green,pink]
      jump 25,-75
      for y in [yellow,orange,red]
        dot x, 21
        dot y, 7
        fd 25


Draw a flower garden using at least double loops.  I encouraged students to use triple loops or as many as they fancy.  I also mentioned that I didn't get to review functions but that could be handy for them to use for this homework.  Some of them seemed intrigued and I am hopeful that they will do their own review of functions to do this homework.

No comments:

Post a Comment