Tle7 - 8-Ict-Programming For Robotics W7

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

8

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.

DEVELOPMENT TEAM OF THE MODULE

Writers : Chito B. Macabudbud


Editor : Ma. Mariza A. Maglangit, PSDS, District 6
Reviewers : Reynold Q. Velos, EPSVR
Illustrator :
Layout Artist :
Plagiarism Detector Software : PlagiarismDetector.com
Grammarly Software : CitationMachine.com

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

Department of Education – Regional Office 7


DepED-Division of Lapu-Lapu CIty
Office Address : B. M. Dimataga Street, Poblacion, Lapu-Lapu City
Telefax : (032) 340 7887
E-mail Address : [email protected]

ii
Property of DepED-Division of Lapu-Lapu City | www.depedlapulapu.net.ph | (032) 340-7354
INTRODUCTORY MESSAGE

For the facilitator:

Welcome to Technology and Livelihood Education (TLE Self-Learning Module


on Programming for Robotics.

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.

For the learner:

Welcome to the Technology and Livelihood Education (TLE Self-Learning


Module on Programming for Robotics.

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

What I Need to Know


This will give you an idea of the skills or competencies you are expected to
learn in the module.

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.

At the end of this module, you should be able to:


Content Standards:
A. demonstrate understanding of how to use for loops to create different
shapes.
Performance Standards:
A. Create art using codes.
Learning Competency:

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.

DepED-Division of Lapu-Lapu City 1 TLE/TVE/TVL


What I Know
This part includes an activity that aims to check what you already know about
the lesson to take. If you get all the answers correctly (100%), you may decide
to skip this module.
Pre-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. 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?

Code block and image from code.org


DepED-Division of Lapu-Lapu City 2 TLE/TVL
A. 3 C. 4
B. 5 D. 6

Test B. True or False

Direction. Carefully read each statement. Write True if the statement is true
and False if it is otherwise.

_____________1. For loops have a predetermined beginning, end and increment.


_____________2. The counter variable will be increased after the sequence of code is
run.
_____________3. The counter will run once even if the step value or increment is
greater than the ending value.
_____________4. For loops doesn’t tract values.
_____________5. For counter from 3 to 9 count by 3. The loop will run more than 3
times.

Refer to Answer Key

DepED-Division of Lapu-Lapu City 3 TLE/TVL


What’s In
This is a brief drill or review to help you link the current lesson with the
previous one.

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?

Image from code.org curriculum

You will learn to create these drawings in this module.

DepED-Division of Lapu-Lapu City 4 TLE/TVL


What Is It
This section provides a brief discussion of the lesson. This aims to help you
discover and understand new concepts and skills.

For loop is a block of code used to repeat a sequence of code a specified


number of times like the repeat loops. The only difference is that for loop can track
the value each time the loop is run by using a counter variable to track its value. You
can then use this counter variable inside a repeat block to loop a code.

The counter variable begins counting from a starting value up to an ending


value by a specific increment. Each time the program goes through the loop, the
sequence of code inside the block is run. The step value or increment is then added
to the counter variable. The loop continues to run until the counter reaches or is
greater than the stopping value. Once the for loop stops, the program will continue
where it left off.

Example 1

for counter from 1 to 4 count by 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.

Code blocks and image from code.org

DepED-Division of Lapu-Lapu City 5 TLE/TVL


Example 2
for counter from 4 to 12 count by 4
The loop will run three times.
1. counter = 4
2. counter = 8
3. counter = 12

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.

Code blocks and images from code.org

Now, let us explore how to use loops, repeat loops, counter variables, and other
blocks to create exciting arts.

Art number 1: Stacked Triangles.

Let's try to recreate the stacked triangles below:

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

Image from code.org 1

DepED-Division of Lapu-Lapu City 6 TLE/TVL


Code blocks available:

Code blocks from code.org

Solution:

Code blocks from code.org

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.

DepED-Division of Lapu-Lapu City 7 TLE/TVL


Challenge:

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.)

Image from code.org

Solution:

Code blocks from code.org

Art number 2: Stacked Squares.

Let’s try to recreate the stacked squares below:

Instructions:
These squares start at 15 pixels long. The largest is 300 pixels long, and
each square is 15 pixels larger than the last.

Image from code.org

DepED-Division of Lapu-Lapu City 8 TLE/TVL


Code blocks available:

Code blocks from code.org

Solution:

Code blocks from code.org

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.

DepED-Division of Lapu-Lapu City 9 TLE/TVL


Instructions. Change the previous code to create this spiral art. You need to
remove something.

Image from code.org

Solution:

Code blocks from code.org

The solution is simple, remove the repeat block so that you will not be
creating a square but a spiral.

DepED-Division of Lapu-Lapu City 10 TLE/TVL


What I Have Learned
This includes questions or blank sentence/paragraph to be filled in to
process what you learned from the lesson.

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?

Code blocks and images from code.org


A. 60 degrees C. 89 degrees
B. 110 degrees D. 180 degrees

2. What is the incremental value of creating this art?

Code blocks and images from code.org


A. 2 C. 10
B. 20 D. 50

3. How many degrees will the artist turn right to create this work of art?

Code blocks and images from code.org

DepED-Division of Lapu-Lapu City 11 TLE/TVE/TVL


A. 30 degrees C. 50 degrees
B. 60 degrees D. 72 degrees

4. What will happen when the run is clicked?

Code blocks from code.org

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.

5. What is the result when the code is run?

Code blocks from code.org

A. Two triangles C. pentagon


B. Two squares D. Spiral

TLE 8 Exploratory – Technical Drafting 12 DepED-Division of Lapu-Lapu City


What I Can Do
This section provides an activity which will help you transfer your new
knowledge or skill into real life situations or concerns.

Create your own art with code.


Instruction:

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.

TLE 8 Exploratory – Technical Drafting 13 DepED-Division of Lapu-Lapu City


Assessment
This is a task which aims to evaluate your level of mastery in
achieving the learning competency.

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

TLE 8 Exploratory – Technical Drafting 14 DepED-Division of Lapu-Lapu City


9. What shape is created with this code?

Code blocks from code.org


A. Cube C. Triangle
B. Square D. Spiral

10. How many times will the artist on the right move forward?

Code blocks and image from code.org


A. 2 C. 6
B. 4 D. 8

Test B. True or False

Directions. Read each statement carefully. Write True if the statement is


true and False if it is not true.

_________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.

Refer to Answer Key

TLE 8 Exploratory – Technical Drafting 15 DepED-Division of Lapu-Lapu City


TLE/TVE/TVL 16 DepED-Division of Lapu-Lapu City
Pre-Test True or False Self check
1. A 6. B 1. True 1. C
2. C 7. A 2. True 2. A
3. B 8. D 3. True 3. D
4. A 9. B 4. False 4. C
5. D 10. C 5. False 5. B
Post-Test True of False
1. A 6. D 1. True
2. B 7. C 2. True
3. B 8. A 3. False
4. D 9. B 4. true
5. A 10. C 5. False
Answer Key
References

Code.org.(2020).Lesson 23 for loops with artist. Retrieved from


https://studio.code.org/s/express-2020/stage/23/puzzle/1?section_id=2719130
Code.org.(2020).Lesson 23 for loops with artist. Retrieved from
https://studio.code.org/s/express-2020/stage/23/puzzle/2?section_id=2719130
Code.org.(2020).Lesson 23 for loops with artist. Retrieved from
https://studio.code.org/s/express-2020/stage/23/puzzle/3?section_id=2719130
Code.org.(2020).Lesson 23 for loops with artist. Retrieved from
https://studio.code.org/s/express-2020/stage/23/puzzle/4?section_id=2719130
Code.org.(2020).Lesson 23 for loops with artist. Retrieved from
https://studio.code.org/s/express-2020/stage/23/puzzle/5?section_id=2719130
Code.org.(2020).Lesson 23 for loops with artist. Retrieved from
https://studio.code.org/s/express-2020/stage/23/puzzle/6?section_id=2719130
Code.org.(2020).Lesson 23 for loops with artist. Retrieved from
https://studio.code.org/s/express-2020/stage/23/puzzle/7?section_id=2719130
Code.org.(2020).Lesson 23 for loops with artist. Retrieved from
https://studio.code.org/s/express-2020/stage/23/puzzle/8?section_id=2719130
Code.org.(2020).Lesson 23 for loops with artist. Retrieved from
https://studio.code.org/s/express-2020/stage/23/puzzle/9?section_id=2719130
Code.org.(2020).Lesson 23 for loops with artist. Retrieved from
https://studio.code.org/s/express-2020/stage/23/puzzle/10?section_id=2719130
Code.org.(2020).Lesson 23 for loops with artist. Retrieved from
https://studio.code.org/s/express-2020/stage/23/puzzle/11?section_id=2719130
Code.org.(2020).Code Studio. Retrieved from
https://studio.code.org/docs/spritelab/codestudio_for/
Code.org.(2020).Code Studio. Retrieved from
https://studio.code.org/docs/spritelab/codestudio_repeat/
Code.org.(2020).CS Fundamentals 2019/2020/Express. Retrieved from
https://curriculum.code.org/csf-19/express/23/
http://depedsouthcotabato.org/wp-content/uploads/2020/07/Enclosure-No.-1-
to-DM-CID-No.-081-s.-2020-Key-Stage-K-to-Grade-3-SLM-Template.pdf
https://www.slideshare.net/lhoralight/k-to-12-grade-4-learners-material-in-
science-q1q4
https://www.slideshare.net/daniholic/math-grade-10-learners-module
https://www.officialgazette.gov.ph/1997/06/06/republic-act-no-8293/
https://www.officialgazette.gov.ph/1997/06/06/republic-act-no-8293
https://en.wikipedia.org/wiki/Wikipedia_talk:Tambayan_Philippines
https://www.slideshare.net/lhoralight/k-to-12-grade-4-learners-material-in-
science-q1q4
https://www.slideshare.net/daniholic/math-grade-10-learners-module
https://www.tutorialspoint.com/cprogramming/c_for_loop.htm
http://forums.lightorama.com/topic/50426-help-trying-to-change-a-16ccr-50-
pixel-display-to-a-100-pixel-display/
https://capcloud.com/post/25357659999/time-to-dump-wireframes
https://deasialittle.wordpress.com/coursework/499l/python-programming

DepED-Division of Lapu-Lapu City 17 TLE/TVE/TVL


DepED-Division of Lapu-Lapu City 18 TLE/TVE/TVL

You might also like