Where: at school
when: Monday morning for 2 hours
Note: These activities were based on this program I found in the pencilcode activity directory: Son of Eyes. This was a very productive class because it helped tease out many misconceptions about functions and variables.
Homework DiscussionReviewing the students' accounts this weekend, I saw some programs written for geometry (great!) but no more progress on the function machines and nothing that indicated they had thought about their projects for this term. As a result, we did not discuss homework today ;-<
Simple FunctionThe first challenge was to figure out what this program does:
makeeye = (x, y) ->As usual, reproducing the program and watching it perform was an acceptable strategy. Through the course of this warm-up, we had a chance to review a lot of the mechanics of writing programs, particularly the use of spacing Coffeescript/pencilcode.
b = new Sprite
dot black, 30
dot white, 28
dot limegreen, 14
b.moveto x, y
makeeye -1, 45
Creepy functions and power loopsAs a next version, I gave them a suggestion to integrate this code snippet into their earlier program:
for [0...10] x = random [-200..200]For the most part, they understood what the loop was doing and were comfortable with that piece. However, integrating it with the makeeyes function proved to be a significant challenge and was really helpful for showing that none of the students yet understand the structure of a function. Essentially, no one knew how to run the function again or to run it with new input variables. We stopped the experimenting and talked about the key components of a function:
y = random [-200..200]
- Name and definition
- Input variables
- function call: function name and inputs
A funny surpriseI showed the students one version I made of the creepy eyes program. Gun was the first to test it out. I encourage you to try it out several times with different input variables. See if you can find the little surprise I included for one of our precocious learners.
HomeworkThis term, we want each of the students to work on a project of their own. The homework this week is to write out a detailed description of the project they want to develop. As no one had previously thought about potential projects, we gave them the following categories as suggestions:
- A game: there are many types, including animated games, text-based games, playing against a computer or against a friend, etc
- An animation or a movie
- A drawing (for example, an animal or plant they've learned from Ajarn Wachara)
- A tool to explain some mathematics to the younger students