Wiki Page, AP CSP: Lesson: Built-in Functions and Expressions: Programming: Putting Together the Pieces

Wiki Page
2016-07-21T11:18:41-06:00

Lesson Overview

This lesson plan is designed as a pre-introduction to Module 7: Calculating Realism, which is an introduction to mathematical expressions and functions.

This lesson plan is based upon the "Learning to Program With Alice" (3rd Ed) book by Dann, Cooper and Pausch, Chapter 3 "Programming: Putting together the Pieces".

Included in Chapter 3 is the following Computer Science topic:

Built-in functions and mathematical expressions.

This lesson will focus only on built-in functions and math expressions.

CS Principles Framework

Big Ideas | Enduring Understandings

1. Creativity

1.1 Creative development can be an essential process for creating computational artifacts.

1.2 Computing enables people to use creative development processes to create computational artifacts for creative expression or to solve a problem.

1.3 Computing can extend traditional forms of human expression and experience.

2. Abstraction

2.2 Multiple levels of abstraction are used to write programs or create other computational artifacts.

2.3 Models and simulations use abstraction to generate new understanding and knowledge.

4. Algorithms | 4.1 Algorithms are precise sequences of instructions for processes that can be executed by a computer and are implemented using programming languages.

5. Programming

5.1 Programs can be developed for creative expression, to satisfy personal curiosity, to create new knowledge, or to solve problems (to help people, organizations, or society).

5.2 People write programs to execute algorithms.

5.3 Programming is facilitated by appropriate abstractions.

5.4 Programs are developed, maintained, and used by people for different purposes.

Student Learning Objectives

By the end of this lesson, students should be able to:

Describe/Explain Functions.

Functions are statements that can be used to in Alice to ask questions about properties of the World or properties of an object within it.

Functions can also be used to compute a value.

Explain that when a function is called, it returns a particular type of value. This value can be a:

number (e.g. 5 or -19.5)

Boolean value (true or false)

string (e.g., "hello world")

object (e.g., a spiderRobot)

Describe/Explain Expressions.

An expression may use an arithmetic operation (addition, subtraction, multiplication, division) to compute a numeric value.

Assessment/Evidence

At the end of the lesson, the students should reproduce the following Alice World: FirstEncounterDistanceFunction.a2w.

Google Portfolio Reflection.

Students will reflect on their success or non-success (challenges, barriers) of reproducing the FirstEnounterDistantceFunction Alilce World using built-in functions and expressions.

Students will relate the big ideas with this programming exercise.

Lesson Review

Students create the First Encounter using the Distance Function with this program.

Steps for Creating the Program

1. Open the LopezAFirstEnounterDistanceFunctionSetup-2.a2w world.

2. Rename the file: FirstEncounterDistanceFunction.a2w.

3. Scenario. "Although we have the spiderRobot moving toward the alien, let us make it more realistic. Functions allow you to get information such as the distance from the spiderRobot to the rocks or the distance from the spiderRobot to the lunarlander."

4. Do the following.

1. Open the Investigate method.

2. Select the spiderRobot from the Object tree and then its functions tab.

4. Describe the following subcategories within the built-in functions:

1. Proximity: how close the object is to some other object in the world (such as distance to, distance above).

2. Size: dimensions such as height, width and depth, and how these compare to the dimensions of another object in the world.

3. Spatial Relation: orientation compared to another object in the world (such as to left of, to right of).

4. Point of view: position in the world.

5. Other: miscellaneous items such as the name of a subpart of the object.

5. In the First Encounter world, the spiderRobot wants to get closer to the alienonwheels. Problem: we do not know exactly how far away the spiderRobot is from the rocks where the alien is hiding.

6. We can find out how far the spiderRobot is by trial and error, moving the spiderRobot different distances to the rocks and alienonwheels, but there is a more efficient way.

7. Let us use the function to ask the question: "What is the spiderRobot's distance to the rock where the alienonwheels is hiding?".

8. Alice will return the value of the distance in meters.

9. Drag the spiderRobot's distance to function tile into the editor and drop it on top of the 1 meter distance of the spiderRobot move forward tile.

11. Select rock as the target object.

12. Press Play to test.

13. Problem! There is a collision between the spiderRobot and Rock. Why this is happening?

1. Answer: A collision occurs because the distance to is measured from the spiderRobot's center point to the rock's center point.

2. How can we avoid a collision? Use a (mathematical) expression to adjust the distance.

14. Can you come up with an idea for a solution to this problem?

15. The rock is bigger than the spiderRobot. If the width of the rock is subtracted from the distance between the two objects, then we adjust the distance further by subtracting an additional small amount, a collision can be avoided.

1. Tricky part or tip: we need to provide a placeholder where we can place a number so that we can build the expression.

2. Let us first select the math operator minus by doing the following.

1. Click on the far right down arrow of the spiderRobot distance to rock function.

3. From the pop-up menu, select math.

4. Select spiderRobot distance to rock - >.

5. Select 1; the number does not matter; it is a place holder.

7. TIP: The reason we selected 1 is because we can now replace the 1 with any of the functions that are available on Alice.

8. We will now substitute the rock's width function where the 1 is located at.

9. Select the rock object in the Object Tree.

10. Make sure the Function tab is selected.

11. Select the rock's width function tile.

12. Drag and drop the rock's width function tile into the -1 placeholder.

14. Press Play to test.

15. Now the spiderRobot moves forward to the rock without a collision.