## Monday, February 16, 2015

### Functions review and projects 2 (programming class 16)

Where: at school
when: Monday morning for 2 hours

Reminder, this is our standard lesson plan for the rest of the term:
1. New or review concepts: For loops, functions, if statements. Often, this will be integrated with the exercises.
2. Exercises related to the projects
3. Project work

# New/Review

The new concept today was the random function. We played with three snippets of code to understand how this works and, of course, keep practicing for loops:

1. Generate 4 random integers between 1 and 10 (inclusive)
2. Modify the previous program to multiple your random numbers by 10
3. Change the first program to generate numbers in [10, 100]
We had a good discussion about these programs: first identifying the ranges for possible values, then drawing Venn diagrams and talking about intersections and subsets. This opportunity to talk about additional math concepts is one of the extra dividends from the programming class.

Using the random function has many applications for games. In the projects this term, I expect that Kan and Boongie will use it to help create new mazes each time the program is run, Win will use it to generate a new set of math questions, and Titus will use it to shuffle the picture cards.

For our review, I wanted to reinforce the ideas related to functions. In one of our last sessions, we realized that the kids didn't really understand function definitions, calls, and variables. This time, i gave them three code snippets:

• Define hypotenuseStep1(a, b) = a+b
• Define hypotenuseStep2(a,b) = a*a + b*b
• Define hypotenuseFinal(a,b) = sqrt(a*a+b*b)
I wanted to see if they could figure out how to call the function and whether they would do anything with the output. After many interesting attempts, we went through the details again and explained how the components work. In retrospect, I should have given them a function that would generate visual output once called. As it was, they needed to get two things right (call the function correctly and write the output) in order to get positive feedback.

# Project Exercises

As noted above, the exercises on random have several potential applications in the projects. The other exercise today was most directly related to Win's project. We combined for loops, random, and write statements to loop through some math statements.

Here are some ideas for future project exercises, particularly using functions:
(1) reset/restart the game
(2) B: draw random gaps in circles for maze
(3) Gan: maybe randomize drawing of maze, depends on how he plans to structure the maze
(4) T: check to see if chosen cards match the next picture symbol

# Projects and homework

The students are all making reasonable progress on their projects. I have stored copies of their work up to the start of today's class in this folder: Project Directory. The homework this week:

• Kan: finish drawing his maze. Next module is to decide what penalty he wants when the turtle runs into the wall.
• Boongie. implement the penalty when the turtle runs into the wall, the turtle bounces back to a previous shell in the maze. There are several ways to do this and I'm curious to see his approach.
• Win: create a looping function so that they get a second chance for an incorrect answer. Next module is to think about gradations in how hard the questions are.
• Titus: arrange the memory cards into a grid, randomize each time the game is played, if possible. Next module is to think about how to check to see if the player chooses a match.