Iteration: Loops
August 4, 2021
Expanding Computer Science Education to ALL Students
CS4All
Flow structure controls
Day 2
Day 4
Day 3
Expanding Computer Science Education to ALL Students
CS4All
SFSU
Recap Day 2
Sequence
Expanding Computer Science Education to ALL Students
CS4All
Recap
Reset
Places Please!
Expanding Computer Science Education to ALL Students
CS4All
SFSU
Variation
Reset
Places Please!
Expanding Computer Science Education to ALL Students
CS4All
SFSU
Flow Structure Controls,
Algorithm building blocks
Sequence
Iteration
Selection
Expanding Computer Science Education to ALL Students
CS4All
SFSU
What are building blocks?
Sequence
Iteration
Selection
Expanding Computer Science Education to ALL Students
CS4All
SFSU
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
Expanding Computer Science Education to ALL Students
CS4All
SFSU
Make a Pattern
10
Expanding Computer Science Education to ALL Students
CS4All
SFSU
Pattern Recognition
11
x 6
Expanding Computer Science Education to ALL Students
CS4All
SFSU
What about these?
4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 = ?
Expanding Computer Science Education to ALL Students
CS4All
SFSU
What about these?
4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 = ?
Or
4 x 8 = ?
Expanding Computer Science Education to ALL Students
CS4All
SFSU
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
Let’s think of other examples
Interactive StoryTelling
1. Think of sequence of story components
2. What about “groundhog day” movie?
Small Group Discussion 1
Please choose one or two topics below and discuss in your group.
Please use this padlet like yesterday! (Please mark which questions your group discuss)
Expanding Computer Science Education to ALL Students
CS4All
SFSU
17
Expanding Computer Science Education to ALL Students
CS4All
SFSU
18
Nested
Expanding Computer Science Education to ALL Students
CS4All
SFSU
The Chicken Dance
19
Make a Chicken Dance Algorithm using loops!
Expanding Computer Science Education to ALL Students
CS4All
SFSU
The Chicken Dance Decomposed
20
Expanding Computer Science Education to ALL Students
CS4All
SFSU
Chicken Dance steps without loops
21
Chorus:
Expanding Computer Science Education to ALL Students
CS4All
SFSU
The Chicken Dance!
22
4x
4x
4x
4x
Expanding Computer Science Education to ALL Students
CS4All
SFSU
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
Verse with Loops!
24
Loop 10
Expanding Computer Science Education to ALL Students
CS4All
SFSU
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
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
Small Group Discussion 2
Please choose one or two topics below and discuss in your group.
Please use this padlet like yesterday! (Please mark which questions your group discuss)
Expanding Computer Science Education to ALL Students
CS4All
SFSU
Unpacking Loops
28
1
2
{
{
Expanding Computer Science Education to ALL Students
CS4All
SFSU
Unpacking Loops
29
Which two of these scripts will do the same thing?
Expanding Computer Science Education to ALL Students
CS4All
SFSU
Unpacking Loops
30
{
{
{
1
2
3
Expanding Computer Science Education to ALL Students
CS4All
SFSU
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
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
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
Learning Trajectory
Researchers at the University of Chicago developed a learning trajectory of students understanding of loops.