1 of 34

Iteration: Loops

August 4, 2021

Expanding Computer Science Education to ALL Students

CS4All

2 of 34

Flow structure controls

Day 2

Day 4

Day 3

Expanding Computer Science Education to ALL Students

CS4All

SFSU

3 of 34

Recap Day 2

Sequence

Expanding Computer Science Education to ALL Students

CS4All

4 of 34

Recap

Reset

Places Please!

Expanding Computer Science Education to ALL Students

CS4All

SFSU

5 of 34

Variation

Reset

Places Please!

Expanding Computer Science Education to ALL Students

CS4All

SFSU

6 of 34

Flow Structure Controls,

Algorithm building blocks

Sequence

Iteration

Selection

Expanding Computer Science Education to ALL Students

CS4All

SFSU

7 of 34

What are building blocks?

Sequence

Iteration

Selection

Expanding Computer Science Education to ALL Students

CS4All

SFSU

8 of 34

What are building blocks?

What are building blocks of music?

What are building blocks of DNA?

What are typical tools for cooking in your kitchen?

What are all your interfaces while driving?

Expanding Computer Science Education to ALL Students

CS4All

SFSU

9 of 34

9

Expanding Computer Science Education to ALL Students

CS4All

SFSU

10 of 34

Make a Pattern

10

Expanding Computer Science Education to ALL Students

CS4All

SFSU

11 of 34

Pattern Recognition

11

x 6

Expanding Computer Science Education to ALL Students

CS4All

SFSU

12 of 34

What about these?

4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 = ?

Expanding Computer Science Education to ALL Students

CS4All

SFSU

13 of 34

What about these?

4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 = ?

Or

4 x 8 = ?

Expanding Computer Science Education to ALL Students

CS4All

SFSU

14 of 34

What about these?

4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 = ?

Or

4 x 8 = ?

How many seconds in a min? How many seconds in an hour? How many seconds in a day?

Expanding Computer Science Education to ALL Students

CS4All

SFSU

15 of 34

Let’s think of other examples

Interactive StoryTelling

1. Think of sequence of story components

2. What about “groundhog day” movie?

16 of 34

Small Group Discussion 1

Please choose one or two topics below and discuss in your group.

  1. There are several building blocks in programming. Loop is one of them. How do you feel about these building blocks? How can you present them in your teaching?
  2. Pattern Recognition is important process in problem solving. How do you feel about the process? Are given examples helpful to understand? How would you present them in your teaching?
  3. What do you think of “iteration”? What do you feel comfortable and what do you feel uncomfortable? Questions or challenges from pre-work?

Please use this padlet like yesterday! (Please mark which questions your group discuss)

Expanding Computer Science Education to ALL Students

CS4All

SFSU

17 of 34

17

Expanding Computer Science Education to ALL Students

CS4All

SFSU

18 of 34

18

Nested

Expanding Computer Science Education to ALL Students

CS4All

SFSU

19 of 34

The Chicken Dance

19

Make a Chicken Dance Algorithm using loops!

Expanding Computer Science Education to ALL Students

CS4All

SFSU

20 of 34

The Chicken Dance Decomposed

20

Expanding Computer Science Education to ALL Students

CS4All

SFSU

21 of 34

Chicken Dance steps without loops

21

Chorus:

Expanding Computer Science Education to ALL Students

CS4All

SFSU

22 of 34

The Chicken Dance!

22

4x

4x

4x

4x

Expanding Computer Science Education to ALL Students

CS4All

SFSU

23 of 34

The Chicken Dance!

23

4 x

4 x

4 x

4 x

INTRO

4 x

1 x

2 x

2 x

4 x

4 x

4 x

4 x

10 x

CLOSING

Expanding Computer Science Education to ALL Students

CS4All

SFSU

24 of 34

Verse with Loops!

24

Loop 10

Expanding Computer Science Education to ALL Students

CS4All

SFSU

25 of 34

Other examples of Nested Loop

How is an image handled in programming?

What about maze game?

Expanding Computer Science Education to ALL Students

CS4All

SFSU

26 of 34

Other examples of Nested Loop

How about calendar?

Calendar handles month-by-month

In each month, calendar handles week-by-week

In each week, there are 7 days,

In each day, there are 24 hours

Expanding Computer Science Education to ALL Students

CS4All

SFSU

27 of 34

Small Group Discussion 2

Please choose one or two topics below and discuss in your group.

  • How do you feel about the loop and nested loop? Do you feel too rushed to talk about the loop and the nested loop together?

  • Are given examples helpful to understand the nested loop? How might you present the concept of nested loop in the context of your current (non-CS) classroom?

  • How might you present the concept of nested loop in the context of your students’ unique cultures and experiences?

Please use this padlet like yesterday! (Please mark which questions your group discuss)

Expanding Computer Science Education to ALL Students

CS4All

SFSU

28 of 34

Unpacking Loops

28

1

2

{

{

Expanding Computer Science Education to ALL Students

CS4All

SFSU

29 of 34

Unpacking Loops

29

Which two of these scripts will do the same thing?

Expanding Computer Science Education to ALL Students

CS4All

SFSU

30 of 34

Unpacking Loops

30

{

{

{

1

2

3

Expanding Computer Science Education to ALL Students

CS4All

SFSU

31 of 34

Unpacking Loops

31

With a partner, talk through the sequence of this script.

Where is the iteration? Why is it used in this script?

Expanding Computer Science Education to ALL Students

CS4All

SFSU

32 of 34

Types of Loops

Count-controlled (for) loops repeat the same steps a specific number of times, regardless of the outcome.

Condition-controlled loops will keep repeating the steps over and over, until it gets a specific result.

Infinite (forever) loops repeat the same steps endlessly, and it has no terminating condition

32

Expanding Computer Science Education to ALL Students

CS4All

SFSU

33 of 34

Types of Loops

Count-controlled (for) loops repeat the same steps a specific number of times, regardless of the outcome.

Condition-controlled loops will keep repeating the steps over and over, until it gets a specific result.

Infinite (forever) loops repeat the same steps endlessly, and it has no terminating condition

33

Expanding Computer Science Education to ALL Students

CS4All

SFSU

34 of 34

Learning Trajectory

Researchers at the University of Chicago developed a learning trajectory of students understanding of loops.