Tle7 - 8-Ict-Programming For Robotics W7
Tle7 - 8-Ict-Programming For Robotics W7
Tle7 - 8-Ict-Programming For Robotics W7
Technology and
Livelihood
Education (TLE)
ICT- Programming for
Robotics
Week 7
i
Technology and Livelihood Education Grade 8
Self-Learning Module-Programming for Robotics
Week 7
First Edition, 2020
Republic Act 8293 section 176 states that: No copyright shall subsist in any work
of the Government of the Republic of the Philippines. However, prior approval of the
government agency or office wherein the work is created shall be necessary for
exploitation of such work for profit. Such agency of office may, among other things.
Impose as a condition the payment of royalties.
Borrowed materials (i.e., songs, stories, poems, photos, brand names, trademarks,
etc.) included in this book are owned by their respective copyright holders. Every
effort has been exerted to locate and seek permission to use these materials from
their respective copyright owners. The publisher and authors do not represent nor
claim ownership over them.
Management Team:
Schools Division Superintendent : Dr. Wilfreda D. Bongalos CESO V
Assistant Schools Div. Superintendent : Dr. Marcelita S. Dignos CESO VI
Chief Education Supervisor, CID : Dr. Oliver M. Tuburan
Education Program Supervisor, LRMDS : Mrs. Teresita A. Bandolon
Education Program Supervisor, TLE : Reynold Q. Velos
ii
Property of DepED-Division of Lapu-Lapu City | www.depedlapulapu.net.ph | (032) 340-7354
INTRODUCTORY MESSAGE
This module was designed, developed, and reviewed by educators both from public
and private institutions to assist you, the teacher or facilitator in helping the
learners meet the standards set by the K to 12 Curriculum while overcoming their
personal, social, and economic constraints in schooling.
This learning resource hopes to engage the learners in guided and independent
learning activities at their own pace and time. Furthermore, this also aims to help
learners acquire the needed 21st-century skills while taking into consideration
their needs and circumstances.
As a facilitator, you are expected to orient the learners on how to use this module.
You also need to keep track of the learners’ progress while allowing them to manage
their learning. Furthermore, you are expected to encourage and assist the learners
as they do the tasks included in the module.
This module was designed to provide you with fun and meaningful opportunities for
guided and independent learning at your own pace and time. You will be enabled to
process the contents of the learning resource while being an active learner.
iii
HOW TO USE THE MODULE
Welcome!
This module is about loops that intend to enhance the learner’s creative
thinking skills and mathematical skills in programming. This module will
teach the learners the basics of programming language in a fun and non-
intimidating way.
The activities are designed and chosen specifically to help the learners code
with or without a computer. Each topic is complete with examples,
illustrations, and explanations.
Make the best use of this module. Complete the previous lesson before
thoroughly engaging in this module. That way, it will be easier for you to
understand the lessons.
Carefully read the information sheets in each section and check your acquired
knowledge by answering the self-check. At the end of each section, perform
the task to test your knowledge and skills. Assess your performance by using
the provided performance criteria checklist.
You can apply what you learned if you have access to the internet for just an
hour. Go to the code.org website and sign in using your Facebook account or
other accounts. If you have questions, feel free to ask your teacher/facilitator.
Happy coding!
iv
Lesson 1 – For Loops
This lesson is designed with you in mind to help you learn further the concept
of for loops and how to use it in a creative and fun way.
1. Use `for` loops to change the loop several times with different values.
2. Recognize when to use a `for` loop and when to use other loops such as
`repeat` loops.
1. A loop is an instruction:
A. that is repeated C. That is tedious
B. that is run once D. That is complex
2. Repeats a sequence of code a specified number of times, and tracks a value each
time the loop is run.
A. Repeat loops C. For loops
B. While loops D. Do while loops
3. The counter variable starts with:
A. A number C. A starting sequence
B. A starting value D. A starting loop
4. What do For loops use to track a value?
A. Counter variable C. Pre-determined number
B. Set variable D. Sequenced value
5. The value to add to the counter variable each time the loop is run
A. Ending value C. Starting value
B. Variable D. Step value
6. The default name is “counter”, Which keeps track of the number that controls
the loop.
A. Ending value C. Starting value
B. Variable D. Step value
7. The value the counter variable must reach before the loop end.
A. Ending value C. Starting value
B. Variable D. Step value
8. The counter starts at 2, ends at 10, has an interval of 2. How many times will
the counter run?
A. 1 C. 3
B. 4 D. 5
9. If a counter starts at 4, ends at 10, has an interval of 3, how many times will the
counter run?
A. 2 C. 4
B. 3 D. 5
10. How many times will the artist on the right move forward?
Direction. Carefully read each statement. Write True if the statement is true
and False if it is otherwise.
In the previous lesson, we learned that for loops are very important in
computer science since they can make a longer code shorter. To accomplish this,
critical thinking and mathematical skills are very important. This week you will
continue to use for loops to create a complex design.
What’s New
In this portion, the new lesson will be introduced to you in various ways; a
story, a song, a poem, a problem opener, an activity or a situation.
What can you say about the drawing below? How might a computer draw this?
Example 1
The loop will run four times. (See the code below)
1. counter = 1
2. counter = 2
3. counter = 3
4. counter = 4
This code will move the sprite four times forward while drawing with her pen four
times. A random set color block is added to the loop so that as the character moves
forward, the color changes as well.
This code will move the sprite three times forward while drawing with her pen
three times. A random set color block is again added to the loop so that as the
character moves forward, the color changes as well.
Now, let us explore how to use loops, repeat loops, counter variables, and other
blocks to create exciting arts.
Instructions:
Use a repeat loop inside a for loop to create this stack of triangles that goes
from 50 to 100 pixels. Use counter for the length of your triangles inside your repeat
loop
Solution:
Explanation:
The instruction is to stack six triangles with a length from 50 pixels to 100
pixels. First, make the loop count from 50 to 100, to be counted by 10, so that the
counter will count 50, 60, 70, 80, 90, and 100. Then, place a repeat counter that
counts three times and place inside it a move forward by counter block and a turn
left by 120 degrees block.
When the code is run, the artist moves 50 pixels forward, turns left by 120
degrees, moves forward 50 pixels, turns 120 degrees left, moves forward 50 pixels,
and turns left by 120 degrees. The three times repeat loop runs out, creating the first
50-pixel triangle. The artist is in the original position to execute the next count (60)
until the counter reaches 100.
Instructions:
Using the same code block above, create these triangles that go from 20-pixel
sides, and where each triangle is 20 pixels larger than the last. (Before seeing the
solution, please draw your code on a separate sheet of paper.)
Solution:
Instructions:
These squares start at 15 pixels long. The largest is 300 pixels long, and
each square is 15 pixels larger than the last.
Solution:
Explanation:
The instruction is to stack squares that start at 15 pixels long. The largest is
300 pixels long, and each square is 15 pixels larger than the last. First, make for
loop to count from 15 to 300, count by 15. Then, we will place a repeat counter that
counts four times (because it’s a square). Place inside it a move forward by counter
block and a turn left by 90 degrees block.
When the code is run, the artist moves 15 pixels forward, then turns left by
90 degrees, moves forward 15 pixels, turns left by 90 degrees, and so on to create
the first square. It will then return to the starting position to start the next counter
and create the next shape. The code runs until the counter reaches 300.
Challenge
Create the art below using the same code above. Before seeing the solution
code, please try to draw your solution on a separate sheet of paper.
Solution:
The solution is simple, remove the repeat block so that you will not be
creating a square but a spiral.
Self-Check
Directions. Study each item carefully. You can use a ruler and protractor to check
your answer. Encircle the letter of the correct answer.
1. How many degrees will the artist have to turn left to create the art below?
3. How many degrees will the artist turn right to create this work of art?
A. The artist will draw a straight line that increases in thickness from
one side of the play space to another.
B. The artist will draw a spiral and each time through the loop, the
line gets longer and thinner.
C. The artist will draw a spiral and each time through the loop, the
line gets longer and thicker.
D. I don’t know.
1. Create a code to draw your favorite art. You can make it colorful.
2. Draw the art on the box below that results from the code you have created.
Rating criteria
Criteria 4 Points 3 Points 2 Points 1 Point
Code matches Exact slight big difference No similarities
the art difference
Aesthetic Amazing Great very good Good
Quality
Complexity of Amazing Great very good Good
shapes
Note: Using paper and pen for this task is perfectly fine. But you may log in to
code.org to experiment with different codes until you are satisfied with your art.
Post-test
Test A. Multiple Choice
Directions. Read each item carefully. Encircle the letter of the correct
answer.
1. A loop is an instruction:
A. that is repeated C. That is tedious
B. that is run once D. That is complex
2. Repeats a sequence of code a specified number of times, and tracks a
value each time the loop is run.
A. Do while loops C. Repeat loops
B. For loops D. While loops
3. The counter variable starts with:
A. A number C. A starting sequence
B. A starting value D. A starting loop
4. The default name is “counter”, which keeps track of the number that
controls the loop.
A. Ending value C. Starting value
B. Step value D. Variable
5. The value the counter variable must reach before the loop end.
A. Ending value C. Starting value
B. Step value D. Variable
6. The counter starts at 2, ends at 10, has an interval of 2. How many times
will the counter run?
A. 1 C. 3
B. 4 D. 5
7. If a counter starts at 4, ends at 10, has an interval of 3, how many times
will the counter run?
A. 1 C. 3
B. 2 D. 4
8. What do For loops use to track a value?
A. Counter variable C. Pre-determined number
B. Set variable D. Sequenced value
10. How many times will the artist on the right move forward?
_________1. The counter variable will be increased after the sequence of code is
run.
_________2. The counter will run once even if the step value or increment is
greater than the ending value.
_________3. For loops doesn’t tract values.
_________4. For loops have a predetermined beginning, end and increment.
_________5. For counter from 3 to 9, count by 3. The loop will run more than three
times.