logo lesson 3 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Logo Lesson 3 PowerPoint Presentation
Download Presentation
Logo Lesson 3

Loading in 2 Seconds...

play fullscreen
1 / 36

Logo Lesson 3 - PowerPoint PPT Presentation


  • 175 Views
  • Uploaded on

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.

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

Logo Lesson 3


An Image/Link below is provided (as is) to download presentation

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
    1. Logo Lesson 3 TBE 540 Fall 2004 Farah Fisher

    2. 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

    3. Objectives for Lesson 3 • 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.

    4. Logo Screen Positions • 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.

    5. Logo Screen Positions • 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.

    6. Logo Screen Positions • 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.

    7. Guess the Positions • Make your best guess about the positions. Click to see the answers. 2 1 4 3

    8. Guess the Positions • Possible screen positions (depending on Logo version) [-100 50] 2 1 [ 150 75] 4 [ 25 -25] 3 [0 -50]

    9. Position Commands • 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 ]

    10. Challenge • 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

    11. Challenge • The commands make a square! [0 25] [25 25] [25 0] [0 0]

    12. Logo Variables • 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

    13. Logo Variables • 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

    14. Logo Variables • 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

    15. Logo Variables • :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)

    16. Logo Variables • 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 ]

    17. RANDOM • 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.

    18. RANDOM • 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)

    19. Samples of Procedures with Variables (MAKE/RANDOM) • A variable size SQUARE • TO SQUARE • MAKE “SIZE 10 + RANDOM 100 • REPEAT 4 [FD :SIZE RT 90] • END

    20. Samples of Procedures with Variables (MAKE/RANDOM) • A variable size TRIANGLE • TO TRIANGLE • MAKE “SIZE 25 + RANDOM 50 • REPEAT 3 [FD :SIZE RT 120] • END

    21. Samples of Procedures with Variables (MAKE/RANDOM) • 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

    22. Another Way to Fill a Variable • 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.

    23. Another Way to Fill a Variable • 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.

    24. Another Way to Fill a 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.

    25. Another Way to Fill a Variable • 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

    26. Self Check Lesson 3 • In the screen below, what is the best estimate of the turtle’s position? • [-50 50] • [50 -50] • [50 50] • [-50 -50]

    27. Self Check Lesson 3 • In the screen below, what is the best estimate of the turtle’s position? • [-50 50] • [50 -50] • [50 50] • [-50 -50] 50 -50

    28. Self Check Lesson 3 • Which of the following could not be the name of a Logo variable? • :Z • :The Size • :SIZE • :B123

    29. Self Check Lesson 3 • Which of the following could not be the name of a Logo variable? • :Z • :The Size {no spaces allowed} • :SIZE • :B123

    30. Self Check Lesson 3 • What will be the value of :BIG after the Logo commands below? • MAKE “BIG 5 • MAKE “BIG :BIG + 25 • MAKE “BIG :BIG - 7

    31. Self Check Lesson 3 • 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}

    32. Self Check Lesson 3 • 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

    33. Self Check Lesson 3 • 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

    34. Self Check Lesson 3 • 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

    35. Self Check Lesson 3 • 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

    36. Try Some Exercises • 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