Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Programming.

Similar presentations


Presentation on theme: "Computer Programming."— Presentation transcript:

1 Computer Programming

2 Recap A computer program is a sequence of instructions in a limited language that when executed in the correct order accomplish a specific on a computer Concepts: Looping Code reuse Syntax This course is more about problem-solving, than computers You need to find your own level, and try to learn something new or practice something you’ve learned, every lesson Don't compare yourself with other students in the class!

3 Difficulties Last time we learnt how to use a sequence of instructions to get the turtle to do something like draw a square. What if you want to execute the same instructions over and over? What if you want to save your shapes so you can use them next time?

4 The REPEAT statement Syntax Challenge repeat N [commands]
N is the number of times commands are the instructions to repeat Challenge Can you draw a square using the repeat statement? Can you draw a triangle using it? Other polygons?

5 Creating Procedures, Extending the Language
Try telling Logo to draw a square by typing "square" in the command box

6 Creating Procedures, Extending the Language
Click Edall Type the instructions File, Save and Exit

7 Creating Procedures, Extending the Language
Now try again typing "square" in the command box

8 Recap So you can save a set of instructions Give them a name
Use that name to run the instructions This is called creating a PROCEDURE (You will also see "function", "method", "subroutine")

9 Task Create your own procedures for drawing A triangle A pentagon
A hexagon An X shape An asterisk A star

10 Procedures can call procedures
Create more complex patterns by creating procedures that call the procedures you have already made

11 Parameter passing Create a procedure square10 that draws a square of side 10 Create square20, square30, …, square100 How do the procedures differ from each other? There is another way…

12 Important concepts Looping (repeat statement) Named procedures
Parameter passing


Download ppt "Computer Programming."

Similar presentations


Ads by Google