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

Slides:



Advertisements
Similar presentations
RCX Workshop Day 2 Programming with Touch Sensor Light Sensor Repeat CJ Chung Associate Professor of Computer Science Lawrence Technological University.
Advertisements

Love Lifted Me Click here to play The slides advance automatically with the words.
Programming Methodology (1). Iteration Learning objectives explain the term iteration; repeat a section of code with a for loop; repeat a section of.
Advance Data Structure and Algorithm COSC600 Dr. Yanggon Kim Chapter 2 Algorithm Analysis.
CHAPTER 5: Repetition Control Structure. Objectives  To develop algorithms that use DOWHILE and REPEAT.. UNTIL structures  Introduce a pseudocode for.
Programming Concept #2 Iteration. Is just a fancy way of saying that you would like something to repeat more than one time. It is used in any modern programming.
Robot Programming. Programming Behaviors Behaviors describe the actions and decisions of your robot.
©2006 CSUC Institute for Research in Intelligent Systems Introduction to Coding June 15, 2006.
Jennifer Goodall, Nick Webb, Katy DeCorah
Loops and Switches. 1. What kind of blocks are these? 2. Name two kinds of controls that can be specified to determine how long a loop repeats. 3. Give.
Flowol subroutines Subroutines are used to:  Simplify your code to make it easier to read (or for someone.
Algorithms In general algorithms is a name given to a defined set of steps used to complete a task. For example to make a cup of tea you would fill the.
Λλ Fernando Magno Quintão Pereira P ROGRAMMING L ANGUAGES L ABORATORY Universidade Federal de Minas Gerais - Department of Computer Science P ROGRAM A.
Robot Programming. Programming Behaviors Behaviors describe the actions and decisions of your robot.
Using MIT Scratch for Programming and Control Exercise 1 Creating movement Year 11 DTG 2012.
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
Algorithms and Pseudocode
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Casne.ncl.ac.uk Taking care of the CrumbleBot Please do NOT stress the robot's motors 1.Do NOT push the robot 2.Do NOT hold the.
An Introduction to Programming Using Alice 2.2, Second Edition Chapter 7 Recursive Algorithms.
26/06/ Iteration Loops For … To … Next. 226/06/2016 Learning Objectives Define a program loop. State when a loop will end. State when the For.
EV3 Binary Bluetooth Functions An Introduction to Brick-to-Brick Communication.
Scratch Programming Cards
Half Turns and Quarter Turns.
Sequencing Learning Objective: to be able to design algorithms that use sequencing.
Basic Steps in Programming
Data Structures.
Broadcasting (Adding a new level)
Add and Subtract Negative Numbers
Selection Learning Objective: to be able to design algorithms that use selection.
NXT-G Binary Bluetooth Functions
Learning Objective: to be able to design programs that use sequencing.
Diamond Hunt Mock Programming Project.
Algorithm Efficiency Algorithm efficiency
Gaming with conditionals
Loops and Switches Pre-Quiz
Learning Outcomes Understand While Loop
LESSON 11 – WHILE LOOPS UNIT 5 – 1/10/17.
Algorithms and Flow Charts
Raspberry Pi: External Inputs & Outputs
Learning to Program in Python
Learning to Program in Python
Sequencing Learning Objective: to be able to design algorithms that use sequencing.
Graph Paper Programming
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Welcome to <INSERT school name>’s
Selection Learning Objective: to be able to design algorithms that use selection.
Line Following Behavior
Global Challenge Night Sensor Lesson 2.
Recap the basics Lesson 1.
Global Challenge Night Sensor Lesson 2.
Global Challenge Night Sensor Lesson 2.
Global Challenge Night Sensor Lesson 2.
Line Following Behavior
3.1 Iteration Loops For … To … Next 18/01/2019.
Learning to Program in Python
Global Challenge Night Sensor Lesson 2.
Global Challenge Night Sensor Lesson 2.
Global Challenge Night Sensor Lesson 2.
Gaming with conditionals
Global Challenge Night Sensor Lesson 2.
Welcome to Mountain View Elementary School!
Motion PowerPoint By Mr. Krall 2011.
Code to Enhance Learning
Recap the basics Lesson 1.
Loops and Switches How Do You Make Loops and Switches? lesson > TeachEngineering.org Center for Computational Neurobiology, University of Missouri.
Moving Sprites at Random
Iteration Learning Objective: to be able to design algorithms that use iteration.
Scratch 7B IT 1.
Learning Objective: to be able to design programs that use iteration.
Presentation transcript:

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

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

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

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.

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

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:

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

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

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:

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

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: