The second lesson is based on conditionals. Conditionals often appear in computer programs as "if" statements.
Dynamic Drive example that allows a button to toggle between opening and closing a menu
To illustrate the concept to students, they drag and drop a colored square onto the sequence to indicate:
- if my Fuzzball comes to a square that matches the color, take the action indicated by the directional arrow
Here is the first example:
Here is the correct solution.
You can see that the Fuzzball will start out by moving forward and then move up when it encounters its first yellow square. The Fuzzball will move forward again and then down when it encounters the second yellow square. The journey is then completed with normal forward, up, and forward moves. Though not the shortest path, this maximizes the number of coins collected which is the object of the exercise.
Eventually, understanding how checking a condition before taking an action leads students to write correct computer programs.
Education is alive in the lab.