1 / 36

# Logo Lesson 3 - PowerPoint PPT Presentation

Logo Lesson 3. TBE 540 Fall 2004 Farah Fisher. Prerequisites for Lesson 3. Before beginning this lesson, the student must be able to… Use simple Logo commands to make a shape. Create and edit a procedure. Use the following commands appropriately POTS SAVE LOAD. Objectives for Lesson 3.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about ' Logo Lesson 3' - qiana

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### Logo Lesson 3

TBE 540

Fall 2004

Farah Fisher

• Before beginning this lesson, the student must be able to…

• Use simple Logo commands to make a shape.

• Create and edit a procedure.

• Use the following commands appropriately

• POTS

• SAVE

• After completing this lesson, the student will be able to…

• Move the turtle to any screen position.

• Determine the turtle’s screen position.

• Explain the term variable.

• Create procedures with variable input, using MAKE and RANDOM.

• The position of the Logo turtle on the screen is described by two numbers - a horizontal and a vertical coordinate.

• The center of the screen is the turtle’s home. Its designation is [0 0], and all other coordinates are measured from there.

• It is very much like graphing in algebra.

• The first of the two numbers describes the horizontal distance in turtle steps right or left of the center.

• For example, in the position [10 15], the 10 represents 10 turtle steps to the right of the center.

• In the position [-25 10], the -25 represents 25 turtle steps to the left of the center.

• The second of the two numbers describes the vertical distance in turtle steps above or below the center.

• For example, in the position [10 15], the 15 represents 15 turtle steps above the center.

• In the position [25 -10], the -10 represents 10 turtle steps below the center.

2

1

4

3

• Possible screen positions (depending on Logo version)

[-100 50]

2

1

[ 150 75]

4

[ 25 -25]

3

[0 -50]

• PR POS is the command used to print (in the command window) the current position of the turtle.

• SETPOS [numbernumber] or SETXY (numbernumber) sets the position of the turtle.

• SETX number changes only the first number

• SETY number changes only the second number

• HOME returns the turtle to [ 0 0 ]

• What shape do you think would result from these commands (assume turtle starts at [0 0])? Click to see the answer.

• SETPOS [ 0 25 ]

• SETPOS [ 25 25 ]

• SETPOS [ 25 0 ]

• SETPOS [ 0 0 ] or HOME

• The commands make a square!

[0 25]

[25 25]

[25 0]

[0 0]

• A variable is a letter or word that represents a number that can vary (thus the term variable).

• In Logo, variables often have a colon in front of the letter or word.

• Sample Logo variables -

• :L2 :WIDTH :NAME :X

• Variables must be assigned a value.

• The Logo command MAKE is often used to “fill up” a variable.

• For example, the command below puts the number 17 into the variable called :NUM (notice the quote and lack of colon)

MAKE “NUM 17

• See if you can determine the final value of :Z after the commands below. (NOTE: * means multiply, / means divide)

• MAKE “Z 25

• MAKE “Z :Z * 2

• MAKE “Z :Z + 10

• MAKE “Z :Z / 2

• :Z becomes 30 after several calculations.

• MAKE “Z 25 (:Z starts at 25)

• MAKE “Z :Z * 2 (:Z is multiplied by 2, :Z = 50)

• MAKE “Z :Z + 10 (10 is added to :Z, :Z = 60)

• MAKE “Z :Z / 2 (:Z is divided by 2, :Z = 30)

• After you define the value of a variable, you can use it in Logo commands in place of any number.

• Examples:

• FD :X

• RT :D2

• REPEAT 4 [ FD :SIZE RT 90 ]

• Logo variables can also be filled with random numbers.

• The RANDOM command returns a number from 0 to a set limit.

• Example: RANDOM 10 returns a number between 0 and 9.

• Example: 1 + RANDOM 100 returns a number between 1 and 100.

• Examples of MAKE with RANDOM

• MAKE “Z RANDOM 15

• :Z becomes a number between 0 and 14

• MAKE “H23 1 + RANDOM 10

• :H23 becomes a number between 1 and 10

• MAKE “LENGTH 10 + RANDOM 50

• :LENGTH becomes a number between 10 and 59 (10 + 0 to 10 + 49)

• A variable size SQUARE

• TO SQUARE

• MAKE “SIZE 10 + RANDOM 100

• REPEAT 4 [FD :SIZE RT 90]

• END

• A variable size TRIANGLE

• TO TRIANGLE

• MAKE “SIZE 25 + RANDOM 50

• REPEAT 3 [FD :SIZE RT 120]

• END

• A variable size RECTANGLE

• TO RECTANGLE

• MAKE “S1 25 + RANDOM 50

• MAKE “S2 25 + RANDOM 100

• REPEAT 2 [FD :S1 RT 90 FD :S2 RT 90]

• END

• You can also fill up a variable by defining it when you “run” a procedure.

• Look at this procedure:

• TO SQUARE :S

• REPEAT 4 [FD :S RT 90]

• END

• Somehow, the :S needs a value.

• To start this procedure…

• TO SQUARE :S

• REPEAT 4 [FD :S RT 90]

• END

• …you would type SQUARE 50 or SQUARE 100 or SQUARE 87

• The number you type after the procedure name fills the variable.

• Another example:

• TO TRIANGLE :F

• REPEAT 3 [FD :F RT 120]

• END

• To draw a triangle with sides of 50, type TRIANGLE 50 to start the procedure.

• Consider this example:

• TO RECTANGLE :L :W

• REPEAT 2 [FD :L RT 90 FD :W RT 90]

• END

• You would need two numbers after the name of the procedure (the first becomes :L and the second becomes :W):

• RECTANGLE 50 100

• RECTANGLE 40 40

• In the screen below, what is the best estimate of the turtle’s position?

• [-50 50]

• [50 -50]

• [50 50]

• [-50 -50]

• In the screen below, what is the best estimate of the turtle’s position?

• [-50 50]

• [50 -50]

• [50 50]

• [-50 -50]

50

-50

• Which of the following could not be the name of a Logo variable?

• :Z

• :The Size

• :SIZE

• :B123

• Which of the following could not be the name of a Logo variable?

• :Z

• :The Size {no spaces allowed}

• :SIZE

• :B123

• What will be the value of :BIG after the Logo commands below?

• MAKE “BIG 5

• MAKE “BIG :BIG + 25

• MAKE “BIG :BIG - 7

• What will be the value of :BIG after the Logo commands below?

• MAKE “BIG 5 {:BIG=5}

• MAKE “BIG :BIG + 25 {:BIG=30}

• MAKE “BIG :BIG - 7 {:BIG=23}

• Suppose you want a randomly chosen number between 1 and 10. Which of the following would generate that number?

• RANDOM 10

• RANDOM 1 + 10

• RANDOM 10 + 1

• Suppose you want a randomly chosen number between 1 and 10. Which of the following would generate that number?

• RANDOM 10 {0 TO 9}

• RANDOM 1 + 10 {10.0 TO 10.999}

• RANDOM 10 + 1

• Suppose you have entered the procedure below. What would you type to use it to draw a SQUARE with sides of 50?

• TO SQUARE :X

• REPEAT 4 [FD :X RT 90]

• END

• SQUARE

• SQUARE 50

• TO SQUARE 50

• Suppose you have entered the procedure below. What would you type to use it to draw a SQUARE with sides of 50?

• TO SQUARE :X

• REPEAT 4 [FD :X RT 90]

• END

• SQUARE

• SQUARE 50

• TO SQUARE 50

• Practice with procedures at http://www.csudh.edu/fisher/tbe540/LW3A.htm

• Check out screen positions at http://www.csudh.edu/fisher/tbe540/LW3.htm

• Try the hand-on exercise at http://www.csudh.edu/fisher/tbe540/LEX3.htm