Presentation is loading. Please wait.

Presentation is loading. Please wait.

Procedures and Variables Control Logo 1. What you will do today  You will make your code more efficient by using procedures  You will create shapes.

Similar presentations


Presentation on theme: "Procedures and Variables Control Logo 1. What you will do today  You will make your code more efficient by using procedures  You will create shapes."— Presentation transcript:

1 Procedures and Variables Control Logo 1

2 What you will do today  You will make your code more efficient by using procedures  You will create shapes using variables by changing the length variables (100 150 200)  You will create a house using shapes by changing sizes(variables) especially the length of the shape  You will create a robot for homework using shapes. 2

3 A Square - inefficiency  This code will make a square, but it is inefficient when it comes to repeating the command to make, for example, 10 squares  Pd  Fd 100  Rt 90  Fd 100  Rt 90  Fd 100  Rt 90  pu The inefficiency occurs because we have made one square but we still have to make another 9! If you did not know any better, you would have to copy and paste this code another 9 times to make 10 shapes. This is time consuming and inefficient 3

4 One Square with our inefficient code 4

5 A Square – efficient  To make the code work for us better, we start to make the code more efficient and introduce procedures that will have variables.  A Variable is ?  Have a guess what is a variable, you have come across it in Spreadsheets and you have hopefully come across it in maths! 5

6 An efficient Square continued  We have to know our maths to make our code better, especially how shapes work.  There are how many sides in a square?  Of course, 4!  4x4 sides make a square 6 Length is variable. It can be 100 or 200 or any number you want.

7 Introducing the length variable  Now you have a square, you can make many squares that are all different sizes.  Code you now know is inefficient To square Repeat 4 [fd 100 rt 90] End This code will only make a length of 100. What if we want to make 4 squares but each one is 100 150 200 and 250 units long? 7

8  With this knowledge we set the square to be 4 sides and we tell logo to build this for us  Code  To Square: repeat 4 [fd 100 rt 90]  Here we have said our shape has 4 sides and we are to go fd 100 with each side and rt 90 with each angle x 4 8

9 Where are the Variables?  Can you see where our variables are? To Square: repeat 4 [fd 100 rt 90] 9 Is it here?

10 Where are the Variables?  Can you see where our variables are? To Square: repeat 4 [fd 100 rt 90] 10 Is it here?

11 Where are the Variables?  Can you see where our variables are? To Square: repeat 4 [fd 100 rt 90] 11 Is it here?

12 Where are the Variables?  Can you see where our variables are? To Square: repeat 4 [fd 100 rt 90 ] 12 All these numbers are variables. All can be changed at any given time to create: 1. A bigger shape 2. to create a brand new shape!  Can you see where our variables are? To Square: repeat 4 [fd 100 rt 90 ]

13  You can see that 100 is a variable  Now, if we leave the code with 100, it is not very useful.  So the variable : Length will help us create a procedure for logo to call up the square and the :length variable will allow us to define how big we want each square to change to:  E.g. 100 to 200 13

14 Now Variable: Length Here is the code, type it in logo TO SQUARE :length REPEAT 4 [FD :length RT 90] END Now call the procedure square 100 square 200 What did you notice? Write up what you noticed and how easy it is to define a variable length! 14

15 The Triangle TO TRIANGLE :length REPEAT 3 [FD :length RT 120] END  Make your triangle  Is your triangle the right way up to make a roof?  Adjust the code to get a triangle with the base on the bottom and the apex at the top!  If you get it the right way up, share the code in your learning page, well done! 15

16 Build your house  Your house needs to look like this Make your house 100 length Make your door appear somewhere in the middle. Put your triangle on the top for a roof! Make a rough plan in your notebooks to help you if you don’t get it first time! First person who gets it, has the credit! If you have used the variable length, fantastic! 16

17 Extension  If you have finished making your house  Colour the door in brown  Colour the main house green  Make the roof red  How about making a bigger house by calling a larger variable compared to your first house in the length section?  Copy and paste your code to your learning page. And explain how you found your colours, what problems you had.  Did you keep the black fill on the edges or were you able to change the fill so that no black pen edges showed? 17

18 Today you have learnt  Write two new things you learnt today you did not know before  You may think about the following  That variables are helpful in procedures by making code more efficient.  Something you have learnt yourself from today that you did not know 18

19 Homework Robot – create a Robot as close as You can to this One! 19


Download ppt "Procedures and Variables Control Logo 1. What you will do today  You will make your code more efficient by using procedures  You will create shapes."

Similar presentations


Ads by Google