Scratch: iteration / repetition / loops

Slides:



Advertisements
Similar presentations
Sprite-visual object (actor on the stage) Scripts- Tells actors (sprites) what to do.
Advertisements

Create a Simple Game in Scratch
Summer Computing Workshop. Introduction to Variables Variables are used in every aspect of programming. They are used to store data the programmer needs.
Create a Simple Game in Scratch
Looping Structures: Do Loops
CS0004: Introduction to Programming Repetition – Do Loops.
CS001 Introduction to Programming Day 3 Sujana Jyothi
Visual Basic.NET BASICS Lesson 10 Do Loops. 2 Objectives Explain what a loop is. Use the Do While and Do Until loops. Use the InputBox function. Use the.
Executes a statement or statements for a number of times – iteration. Syntax for(initialize; test; increment) { // statements to be executed } Initial.
REPETITION (loops or iteration) Schneider: Sec. 6.1 & 6.3.
Copyright © Texas Education Agency, Computer Programming For Loops.
Digital Art in Scratch part 1 Barb Ericson Georgia Tech Oct 2010.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
INTRODUCTION TO THE SCRATCH PROGRAMMING ENVIRONMENT.
Summer Computing Workshop. Session 4 Loops  At the heart of their functionality, loops enable blocks of code to be executed more than once  Loops represent.
Programming & Scratch. Programming Learning to program is ultimately about learning to think logically and to approach problems methodically. The building.
Using Waits, Loops and Switches WAIT please!. Waits, Loops and Switches Pre-Quiz 1. In programming, what is a loop? When is a loop useful? 2. How can.
How to make a Shooting Target game in Scratch!. WE ARE GOING TO MAKE A TARGET GAME. This game will have: A Target that will move when clicked. A Timer.
Scratch Programming Lesson 2 First glance to programming logic.
Mr. Dave Clausen1 La Cañada High School Chapter 6: Repetition Statements.
 There are times when you will want blocks to repeat. Instead of duplicating blocks and ending up with a long script that might be confusing, there.
Digital Art in Scratch part 1 Barb Ericson Georgia Tech May 2011.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Summer Computing Workshop. Session 3 Conditional Branching  Conditional branching is used to alter the normal flow of execution depending on the value.
For Code Next For Code Next A loop is a segment of a code that repeats (changing slightly each time)
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008.
The If Block. IF The “if” block can be found in the control tab. The if block means, “IF this happens, THEN do this.” You can put blocks ON the if block.
For…Next and Do...While Loops! Happy St. Patrick’s Day!
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Control Structures WHILE Statement Looping. S E Q C E N U E REPITITION …a step or sequence of steps that are repeated until some condition is satisfied.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech May 2009.
FOP: While Loops.
Create a Halloween Computer Game in Scratch
Computer Programming.
Broadcasting (Adding a new level)
Chapter 6: Loops.
Programming & Scratch.
Scratch for Interactivity
Unit 3 Lesson 9 Repetition Statements (Loops)
Understanding the Geometric Shape Code
Programming Scratch to Control a K’NEX Fairground Ride
Scratch – Simple Programming
Learning to program with Logo
Loopy Motion Control.
LESSON 11 – WHILE LOOPS UNIT 5 – 1/10/17.
Scratch – Simple Programming
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
Algorithms Take a look at the worksheet. What do we already know, and what will we have to learn in this term?
Introduction to scratch animation
Moving Sprites in Scratch
Chapter 6: Repetition Statements
ICT Programming Lesson 3:
Variables & getting info from the user
Topics Introduction to Repetition Structures
Introduction to Computer Science
Introduction to Repetition
Prepared By: Deborah Becker
Repetition Statements (Loops) - 2
Introduction to Repetition
© A+ Computer Science -
Selections and Loops By Sarah, Melody, Teresa.
Creating a Simple Game in Scratch
CPS120: Introduction to Computer Science
How to allow the program to know when to stop a loop.
Scratch 7B IT 1.
Scratch – Simple Programming
Presentation transcript:

Scratch: iteration / repetition / loops by Mr. Dave Clausen

Iteration (Repetition) - Repeat Command Iteration is computer programming jargon for repeating a section or group of lines of code. It is also called referred to as repetition. Each time the code is executed (repeated) once is called one iteration. The first type of repeat command in scratch is the same as we learned in LOGO. Repeat the section of code a specified number of times. In this example, whatever code is contained inside this repeat command is repeated 10 times. This example will draw a decagon.

Iteration (Repetition) - Repeat UNTIL Command Sometimes you don’t want to repeat code a predetermined number of times. Instead you want to repeat until or while some condition is TRUE. This can be accomplished using a “Repeat Until” block. The “hexagon” shape after the word “until” means we need some type of condition to determine when the “loop” will stop. What type of blocks can be used as conditions in the Repeat Until loop?

Conditionals for repeat until We can find hexagonal shaped conditions under the Sensing (light blue) group and the Operators (green) group. One of the easiest tasks we can do is to move the sprite until it reaches a certain position (see below).

Conditionals for repeat until Continued We can make something repeat until a key is pressed. In this example, “q” to quit. The second example will stop when the mouse is clicked.

Repeat Forever Avoid Repeat Forever whenever possible. Infinite loops are not a good idea. Typically this type of loop requires an “if” statement to “break” out of the loop. In the example below, it requires more lines of code to use a Repeat Forever loop than its equivalent Repeat Until loop.