0% found this document useful (0 votes)
32 views29 pages

Intro to Loops in Programming

The document outlines a class on introductory loops for kids, focusing on understanding and applying loops in programming to optimize processes. It includes class structure, goals, teacher and student resources, and step-by-step activities designed to teach the concept of loops through interactive exercises and examples. The class aims to help students identify repeating patterns in code and replace them with loops to make their programs more efficient.

Uploaded by

1994sumathi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views29 pages

Intro to Loops in Programming

The document outlines a class on introductory loops for kids, focusing on understanding and applying loops in programming to optimize processes. It includes class structure, goals, teacher and student resources, and step-by-step activities designed to teach the concept of loops through interactive exercises and examples. The class aims to help students identify repeating patterns in code and replace them with loops to make their programs more efficient.

Uploaded by

1994sumathi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Topic ​INTRODUCTORY LOOPS

Class Description Applying loops to computer programs for optimizing process


steps. Kids develop tremendous regard for logic, realizing
complex puzzles are created on the foundation of efficient
reasoning.

Class BEG-C6

Class time 55 mins

Goal ● Understand what a loop is


● Identify patterns of repeating code and replace with loops
● Identify where a loop can make instruction more efficient

Teacher Resources ● Teacher Resources


○ Use your [Link] login credentials
○ Earphone with mic
○ Notepad and Pen

● Student Resources
○ Use your [Link] login credentials
○ Earphone with mic (optional)
○ Notepad and Pen

Class Warm Up 3 Mins


structure Teacher-Led Activity(Explanation/Demo/Close) 15 Mins
Student-Led Activity 25 Mins
Wrap Up 2 Mins

Class Steps Say Do

Step 1. Hey, how are you today? Ask the student


Warm up to get into
(5 min) Fullscreen​ mode
What did we do last time?

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
1
[Link] wrote programs or code to draw shapes and
alphabets.

We practised use of ​SEQUENCES​ and Logic to draw art forms.


Isn’t it?

Today we will learn a new concept which will help us code


better

Conduct​ Collaborative Learning-1​ Game App Only if a friends


(Refer Collaborative Learning-1 doc) comes to class

Encourage the
student to answer

Before that let us do a fun exercise. Stand up and I’ll tell you
what to do

On the spot (in one place)

Jump

Jump

Jump

Student to
Jump
execute “JUMP”
on the spot
Jump

Jump
Student to do 6
jumps after each
Would it have been easier for you if I had asked you to command
jump 6 times as 1 instruction?

What if I had to ask you to Jump 10 times?

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
2
This is a ​LOOP​. When we do one activity over and over
again, like jumping 10 times , we call it a LOOP.

When we program, if we want to​ repeat actions we use a


loop​.

Tell me an algorithm to slice a carrot into 10 pieces.


What are the steps you will follow?

Your instruction steps have to be clear and specific such that


even a robot can follow your steps and do the task.

1. Pick carrot
2. Pick knife
3. Slice
4. Slice
5. Slice
6. Slice
7. Slice
8. Slice
9. Slice
10. Slice
11. Slice
12. Slice

Instead of repeating slice, slice, slice, I can state in a single


sentence - slice 10 times.

This is where loops are used. Let us see them in greater detail
in today’s class.

Step 2a:
Teacher-Led Can you think of other activities where you repeat or loop
Activity an instruction?
(3 mins)
Example: Timer in mobile. It reduces time till end of loop
to 0.

Loop is action/s that repeats a certain number of times​.

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
3
In playschool, do you remember how you played the 'Spinning
around' game.
What did you do? You turned round and round until you felt
dizzy and had to stop.

WHILE you are not dizzy


Copy Paste in
{ Chat Box for the
Spin around quickly student to see
}
and then you either FALL DOWN or SIT ON THE GROUND
tired or STOP.

Falling down or sitting down tired is a stopping condition for the


Spin Around loop.

Close the chat


So as you can see, all these are loops we do and use in real window
life.

Now, we’ll take a look at some examples of how loops help us


when writing programs.

Teacher Initiates Screen Share

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
4
Step 2b: Teacher Activity 0
Teacher-Led - ANGRY BIRD
Activity LOOP
(7 mins)

As we see here, the angry bird has to move 3 times East and 4
blocks South/down to reach the naughty pig.
Instead of writing long code for E, E, E, S, S, S, S
Wherever any commands are repeating we know to replace it
with a Loop command or Repeat code block.

So our code for the same will now be Repeat (3 times E block)
and Repeat (4 times S block)

Solution: Teacher Activity


1-HARVESTER

DO NOT USE LOOP (PINK REPEAT BLOCK) THE FIRST


TIME

DO IT THE STANDARD WAY WITH DROPPING COMMANDS


AS MANY TIMES AS NEEDED.

Do the standard
solution first and

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
5
Run to see it
work

Then
Start Over

But, the instructions say pick using 1 move block. How do we


manage that?

Redo the same


puzzle with
Repeat block
solution and run
again
As you have noticed in solution above, our standard steps have
a REPETITION of

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
6
1 Move West and 1 Pick Corn 4 times

So in order to repeat the “move-and-pick” actions over and over


for 4 times, we use the REPEAT block.

Important thing to know is how a ​computer reads a Program


line by line from top to bottom

So, going by our standard solution, This is how it will work

Read Line 1. Go West -- Do Go West 1 block on screen


Read Line 2. Pick Corn -- Do Pick 1 Corn on screen
Read Line 3. Go West -- Do Go West 1 block on screen
Read Line 4. Pick Corn -- Do Pick 1 Corn on screen
Read Line 5. Go West -- Do Go West 1 block on screen
Read Line 6. Pick Corn -- Do Pick 1 Corn on screen
Read Line 7. Go West -- Do Go West 1 block on screen
Read Line 8. Pick Corn -- Do Pick 1 Corn on screen

This way line by line it will go through a long program and act
upon or execute each line.

Instead when we use a Loop… it is reading the entire 1st line


which says
1. Repeat 4 times .. Move-and- Pick

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
7
So, it has read the entire instructions and will now go and act
upon what needs to be done in a single shot.

So ​loops make programs shorter and faster.

Now, I will stop screen share and you will practise writing some
Loop programs

Teacher Stops Screen Share

Step 2c: We saw and learnt that LOOPs are used to repeat an action
Teacher-Led over and over again.
Activity Loops make your programs SMALLER AND FASTER.
(2 mins)
A LOOP is defined by 2 things: 1) Something to do over and
over again and 2) Knowing when to stop.

You keep doing that one thing over and over until you stop.
Every time code blocks inside the loop are run, it is called an
ITERATION.

You will now do some Loop exercises. We will start with the
easy ones and do some slightly difficult practice problems.

Why don’t you share your screen and click on the student panel
activities?

● Ask the Student to press ESC key to come back to panel


● Guide Student to start Screen Share
● Teacher gets into Fullscreen

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
8
Step 3: Student Activity 1
Student-Led -ANGRY BIRD
activity (Do 1 to 11)
(25 mins)

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
9
© 2019 - WhiteHat Education Technology Private Limited.
Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
10
© 2019 - WhiteHat Education Technology Private Limited.
Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
11
© 2019 - WhiteHat Education Technology Private Limited.
Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
12
© 2019 - WhiteHat Education Technology Private Limited.
Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
13
You are now able to write good loops.

Well done, now you can stop screen share and we will revise
what we learnt.

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
14
Excellent, you have learnt to identify the patterns and replace
them with loops. Whenever we see some commands that are
repeating, we should consider changing them into Repeat
blocks using loops.

You did really well identifying repeating patterns and creating


loops from them.

Student Stops Screen Share

We saw how repeating commands can be placed inside a loop


to make the code shorter and run faster

Teacher Initiates Screen Share

Loop makes programs shorter and faster. Teacher Activity


2- LAUREL
Let us do 1 more example together before you can do them ADVENTURER
yourself. (Do 2 and 3)

Notice how as Laurel loops through the steps to find and collect
gems the goal shows how many gems she has collected

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
15
Whenever you have difficulty working out the solution, you must

remember to use the button to see how the


program works through each step of the loop.

Angry Bird puzzle : Teacher Activity 3


- ANGRY BIRD

Teacher to
explain the
solution
according to the
figure

Can you give me the order of commands in the loop?

The angry bird has to go E, followed by N and in this


East-North sequence he has to repeat 3 times to reach the pig .

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
16
In these puzzles above, we see that there is more than 1
command in the loop.

We can give as many commands inside a loop based on a


pattern that evolves.

Solution:

As you can see, the angry bird has to follow the same pattern 3
times. Go E and Go N.

Teacher Stops Screen Share

Student Starts Screen Share

Student Led You have to now solve using ​multiple commands within a loop​. Student Activity 2
Activity (15 The tip here is to look and ​identify a pattern ​before starting to - HARVEST THE
min) code. CORN (Do 6 to 9)

Once you have the pattern, it is easy to replace the repeating


code blocks inside a loop.

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
17
© 2019 - WhiteHat Education Technology Private Limited.
Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
18
© 2019 - WhiteHat Education Technology Private Limited.
Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
19
Puzzle 8: Student Activity 3
- GARDEN LOOP
As you can see it is a pattern of N and W repeatedly for 7 times. (Puzzle 8)

It is a steps/ stairs like pattern.

Let us now see how free flowing art can use loops and create
shapes and patterns.

We have done Artist Lab in last class and we will be using the
same for our next exercise.

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
20
Create > New Pre Reader Artist Lab or click on the link and Student Activity 4
REMIX >> Rename and Save - LOOP ART

You have to create this woven diamond pattern

Teacher to show
the student what
is to be drawn on
screen share
mode

Reference - ART
IMAGE

Student to keep
the image open
for reference
when coding

Solve for 1 Diamond and repeat 7 times.

Note: in the code for the diamond, there is a jump N as the next
diamond starts from the middle of the earlier diamond

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
21
Solution

TEACHER REF
CODE - LOOP
ART

As you saw, this puzzle has a batch of commands inside the


loop which we then repeated 7 times.

The diamond is the repeating pattern. So all code blocks to


draw the diamond art are within a loop.

Excellent. You did very well.

Teacher Guides Student to Stop Screen Share

Step 3: Today we learnt when and how to use Loops.


Wrap-Up
(2 mins) LOOP is used to repeat, actions or steps over and over
again until a condition is met.

A good ​LOOP​ has 2 things properly written:


1) Something to do over and over again inside the loop, and

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
22
2) Knowing the condition for when to stop looping.

Loops make your programs shorter and execute faster.

Repeat (X times) repeats a sequence of action that many times.


Using a Repeat Block command with a number of repetitions
specified, repeats a sequence of action that many times.

Every time a code inside a loop runs, it is called an ​ITERATION.

You did extremely well with the arrow (direction) ​SEQUENCES


and I think its reward time. Which means time to get hats​ off​.
(Give at least 2
hats off)
Press the Hats
Off Icon for
Look out for loops in things you do everyday. Like walking down Creatively
the stairs. We walk left -right-left-right until we come to a Solving
landing. Activities

Walking or running is also a loop.

Press the Hats


Ciao until next class!
Off Icon for ​Great
Question

Press the Hats


Off Icon for
“​Strong
Concentration..​”

Step 5: Project BEG-C6 project : LITTLE STAR


Pointers and
Cues Problem Statement:​ Write program code to draw a Star

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
23
(5 min)
Today, we learnt how to look for repeating command blocks or
patterns in our code.

We need to draw the star using efficient code having loops


using commands in the Artist lab.

Click on the project link >> REMIX it >> Give it a name >> and
Save.
Teacher Project
Refer to the image and proceed to write your command Solution - LITTLE
sequences to create a star picture using loops in code. STAR

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
24
Once done, run and test your project.

Share the link and submit your project for evaluation.

Additional There are multiple ways to solve this. TOSS THE DICE
Activity 1
Since the 2 dice cubes are identical, solve for 1 and we can
replicate for the other.

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
25
Solution below

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
26
© 2019 - WhiteHat Education Technology Private Limited.
Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
27
LINKS-BEG C6

Activity No Name of Activity Links

Teacher Activity 0 ANGRY BIRD [Link]


LOOP

Teacher Activity 1 HARVESTER [Link]


Student Activity 1 ANGRY BIRD [Link]
(Do 1 to 11)

Teacher Activity 2 LAUREL [Link]


ADVENTURER
(Do 2 and 3)

Teacher Activity 3 ANGRY BIRD [Link]

Student Activity 2 HARVEST THE [Link]


CORN (Do 6-9)

Student Activity 3 GARDEN LOOP [Link]


(Do 8)

Reference ART IMAGE [Link]


m/BEG-C7/[Link]

Student Activity 4 LOOP ART [Link]


WAVtprp8QY_wrmEjNKYI509u6Vx67Q

Teacher Ref Code LOOP ART [Link]


Hlu2_sBil1af0sJeSEEPp29JZ_waE

Additional Activity 1 TOSS THE DICE [Link]


04712

Teacher Project Soln LITTLE STAR [Link]


xPb5FiIpebaZlSHexxUmXBzwPkr_Ow

[FRIEND] Teacher [FRIEND] [Link]


Collaborative Learning Collaborative ative+Learning-1+(Maze+Game).pdf
-1 Link Learning -1

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
28
[FRIEND] Teacher [FRIEND] BYF [Link]
Activity 1 GAME V2 gcLRBCPaZWZJtrSXde0ky32yRt22A

[FRIEND] Teacher [FRIEND] BIG [Link]


Activity 2 MAZE MIaIP-WbuKSCIRCUPn8NTwxt5JV7r4

[FRIEND] SOLUTION IS COMMENTED IN THE CODE ITSELF

© 2019 - WhiteHat Education Technology Private Limited.


Note: This document is the original copyright of WhiteHat Education Technology Private Limited.
Please don't share, download or copy this file without permission.
29

You might also like