Presentation is loading. Please wait.

Presentation is loading. Please wait.

Iteration Learning Objective: to be able to design algorithms that use iteration.

Similar presentations


Presentation on theme: "Iteration Learning Objective: to be able to design algorithms that use iteration."— Presentation transcript:

1 Iteration Learning Objective: to be able to design algorithms that use iteration.

2 Right Motor Forward Off
Algorithm Efficiency This algorithm isn’t very efficient as it contains repeated sets of instructions. Start Stop Left Motor Forward On Delay 2 Left Motor Forward Off Right Motor Forward On Right Motor Forward Off

3 Right Motor Forward Off
Iteration Iteration allows us to repeat sets of instructions. This algorithm repeats the same set of instructions forever. Start Left Motor Forward On Delay 2 Left Motor Forward Off Right Motor Forward On Right Motor Forward Off LOOP RightMotor.forward(off) LeftMotor.forward(on) DELAY(2) LeftMotor.forward(off) RightMotor.forward(on) ENDLOOP

4 Predict what this program will do:
Activity 1 Here is the program code for the algorithm given on the previous slide. Predict what this program will do: Prediction: Now write this program and test it on Bobbot.

5 Activity 2 LOOP RightMotor.forward(on) ENDLOOP
Complete this design in pseudocode for an algorithm that will make Bobbot go forwards and backwards continually. LOOP RightMotor.forward(on) ENDLOOP

6 Place a screenshot of your code here:
Activity 3 Use Touch Develop to create the program you designed in activity 2 and test it on Bobbot. Place a screenshot of your code here:

7 This instructions inside this FOR loop will be repeated 10 times.
FOR Loops It is also possible to repeat a group of instructions a set number of times. We use a FOR loop to do this. This instructions inside this FOR loop will be repeated 10 times. FOR X = 1 TO 10: RightMotor.forward(off) LeftMotor.forward(on) DELAY(2) LeftMotor.forward(off) RightMotor.forward(on) ENDFOR Pseudocode Program Code

8 Activity 4 Adapt the algorithm you designed in activity 2 so that the instructions only repeat 5 times.

9 Place a screenshot of your code here:
Activity 5 Use Touch Develop to create the program you designed in activity 4 and test it on Bobbot. Place a screenshot of your code here:

10 Activity 6 Design an algorithm in pseudocode that makes Bobbot move in a zig zag like the pattern shown below:

11 Place a screenshot of your code here:
Activity 7 Use Touch Develop to create the program you designed in activity 6 and test it on Bobbot. Place a screenshot of your code here:


Download ppt "Iteration Learning Objective: to be able to design algorithms that use iteration."

Similar presentations


Ads by Google