Presentation is loading. Please wait.

Presentation is loading. Please wait.

Functions and Expressions

Similar presentations


Presentation on theme: "Functions and Expressions"— Presentation transcript:

1 Functions and Expressions
Note to Instructor: Slides may be used either in a traditional lecture format or with an Active Learning approach. If you are using an active learning approach, suggestions will appear in this "Notes" area on appropriate slides.

2 What will we learn today?
We will learn today What are functions and expressions Functions in real life Built-in functions in Alice How to use functions and expressions

3 Functions and Expressions
A statement you can use to ask a question about conditions/properties of an object or to compute a value Expression A math operation on numbers or other kinds of values

4 Functions in Real-Life
We use functions to compute the hours in any given number of days (hours=days*24) The vending machine; you insert a currency into the machine and it dispenses items such as snacks, chocolates, water..etc to you automatically

5 Functions We use functions to get the information we need
Q:How far away the camel is from the palm trees??

6 Built-in Functions Alice system provides a set of built-in functions for each object To view a list of built-in functions associate with an object in a world Select the object in the object tree View the functions in the details area

7 Built-in Functions The Built-in functions are divided into subcategories Proximity: how close the object is to other objects e.g. distance to Size: dimensions e.g. height, width and depth Spatial relation: orientation compared to other objects in the world e.g. to right of Point of view: position in the world Other: miscellaneous items

8 Expressions Alice Provides math operators for common math expressions
Add(+), subtract(-), multiply (*) and divide(/) Obtaining math expression

9 Camel and distance to tree example
We want the camel to move towards the palm tree and stops there Select the camel from the object tree Click on the methods tab Drag the ‘move’ method and place it into the program code editor (the large yellow pane)

10 Camel and distance to tree example
Choose forward and 1m from the list shown Select the functions tab and drag the ‘distance to’ function under ‘proximity’ into the ‘1 meter’ box

11 Camel and distance to tree example
Choose ‘plamTree’ from the list and the ‘entire plamTree’

12 Camel and distance to tree example
Click on the arrow as shown below and choose math, camel distance to palmTree-1

13 Camel and distance to tree Simulation

14 Let’s work with Alice We will take the “raceCar” simulation and make the car Move to the palmTree Turn to face the lampPost Move forward half the distance to the lampPost


Download ppt "Functions and Expressions"

Similar presentations


Ads by Google