Year 7 · Spring 2

Scratch I: Programming essentials · Lesson 4 of 5

Iteration: count-controlled and condition-controlled loops

PracticalTopic 11 Algorithms

Year 7 · Scratch I: Programming essentials · Lesson 4 of 5

You will learn to

  • Explain the difference between a count-controlled loop and a condition-controlled loop.
  • Use repeat to draw a shape with fewer blocks.
  • Use repeat until to keep going until something happens.
  • Trace a loop and count how many times it runs.

Year 7 · Scratch I: Programming essentials · Lesson 4 of 5

Success criteria

You have got it when you can say:

  • I can draw a square with repeat 4 instead of eight separate blocks.
  • I can make a sprite keep moving until it touches something.
  • I can say how many times a loop will run before I run it.

Year 7 · Scratch I: Programming essentials · Lesson 4 of 5

Retrieval starter

Questions from before. Write your answers, then show them.

  1. Last lesson

    How many times does FOR i ← 2 TO 8 repeat?

    A 7B 6C 8

    A. 7

  2. Last unit

    SELECT FirstName FROM Students WHERE Year = 8; returns…

    A Every field of every studentB Only the first names of Year 8 studentsC The number of Year 8 students

    B. Only the first names of Year 8 students

  3. Earlier this year

    Logging into a friend's account 'just to look' is…

    A Only illegal in SpainB Legal if you change nothingC An offence under the Computer Misuse Act

    C. An offence under the Computer Misuse Act

Year 7 · Scratch I: Programming essentials · Lesson 4 of 5

Key words (1 of 2)

trace table
Records variable values step by step to check logic.
Algorithm
Precise, ordered, finite steps to solve a problem.
Decomposition
Breaking a problem into smaller ones.
Abstraction
Ignoring detail that doesn't matter for the problem.

Year 7 · Scratch I: Programming essentials · Lesson 4 of 5

Key words (2 of 2)

Sequence · selection · iteration
Steps one after another. First this, then this.
Pseudocode
Code-like writing for algorithms, without strict rules.
Variable
A named place in memory that holds a value.

The explanation · step 1 of 1

Trace tables

A trace table records every variable at each step, to check the algorithm works.

Passnn > biggest?biggest after
17No7
23No7
312Yes12
45No12
e.g.Example

Output: 12. Correct.

Year 7 · Scratch I: Programming essentials · Lesson 4 of 5

Try it: Trace 'find the biggest'

Year 7 · Scratch I: Programming essentials · Lesson 4 of 5

Quick quiz · 1 of 3

Which shape is used for OUTPUT total?

  1. A Diamond
  2. B Parallelogram
  3. C Rectangle

B. Parallelogram

Input and output are always parallelograms.

Year 7 · Scratch I: Programming essentials · Lesson 4 of 5

Quick quiz · 2 of 3

Breaking a problem into smaller parts is…

  1. A Iteration
  2. B Abstraction
  3. C Decomposition

C. Decomposition

De-compose = take apart.

Year 7 · Scratch I: Programming essentials · Lesson 4 of 5

Quick quiz · 3 of 3

An 'if… else…' is…

  1. A Sequence
  2. B Selection
  3. C Iteration

B. Selection

It selects one path.

Year 7 · Scratch I: Programming essentials · Lesson 4 of 5

Exit ticket

Answer on paper before you go. Then check.

  1. In a flowchart, a decision is a…

    A DiamondB OvalC Rectangle

    A. Diamond Diamonds have yes/no arrows coming out.

  2. The Tube map leaves out real distances. That's…

    A Pattern recognitionB AbstractionC Decomposition

    B. Abstraction Abstraction removes detail that doesn't matter for the problem.