Cyber Robotics 101 Teacher's Guide
How can finding and using patterns make coding easier?
The lesson introduces the repeat loop, a classic control structure that leverages patterns and repetition to make code easier to use and understand. Students use repeat loops in various contexts, experimenting with different types of shapes and patterns that include repetitions. They combine this new control structure with previous constructs such as the Wait Until block and Smart Blocks to create more sophisticated programs.
Explain the advantages of using loops in a program
Use iteration (repeat loops) to control the flow of a program
Find and use patterns to manage complexity
Explain the advantages of using loops in a program
In the second reflection question, check that students have listed reasonable advantages for Repeat blocks, such as improving readability or making code easier to manage.
Use iteration (repeat loops) to control the flow of a program
Check for successful mission completion in either of the last two missions of the pack.
Find and use patterns to manage complexity
Check for successful mission completion in either of the last two missions of the pack.
Slideshow: The Repeat Loop
Repeat block support article
How can you tell when a Repeat block will be useful in a program?
Student answers should indicate understanding that repeat blocks are used for programs in which one or more commands are repeated right after each other. Programs that have repeating patterns of actions or movement can use loops to make the code easier to read and write.
Why might a programmer use a Repeat block rather than just copy and paste the repeating bits of code into a program?
Student answers may vary, but could include that repeat blocks make code easier to keep track of and understand. Repeat blocks also make it clear exactly how many times a snippet of code is repeated, without need to count up the blocks.
If Smart Blocks and Repeat blocks both let a programmer use the same piece of code many times, how do you know which one to use?
Student answers should include the fact that a Repeat block is useful when a programmer wants to repeat the exact snippet of code over and over in a row. In contrast, Smart Blocks are used when the code snippet will be used in different places in the program, or even in other missions.
Description
Reflection on Object Detection I
Timing
5 minutes
Description
Let students complete Missions: 1-10
Pack: Repeat Loops
Timing
25 minutes
Description
Class Conclusion Questions
Timing
5 minutes
Familiarize yourself with the above resources.
The missions might take longer, either assign it as homework or dedicate next session to complete these missions.
Q1. What does a repeat loop do to the code inside it?
A1. It repeats the code however many times it is set to run.
Q2. What is an iteration, regarding the repeat loop block?
A2. An iteration is the number of times the code will run.
Q3. What happens if you take code that is in a repeat loop of 4 iterations, and put its loop in a loop of 2 iterations?
A3. The code inside the first loop will run 8 times.