Lesson Modules
Teaching Tips:
- Have students talk in groups to figure out what a loop is and how it might be used in programming.
- Split students up into teams and have them choreograph their own dances. The choreography should be 30-60 seconds, school appropriate, and should have at least three repeated series of steps. Once their dance is choreographed, they will need to write out their dance steps and anything that is a loop should have a bracket around the step with loop written next to it. Next, they will pass their written choreography to the team on their left and perform their dance moves according to the instructions. Performances will need to be done one at a time so the team that wrote the choreography can see if their instructions made sense.
- Which groups were successfully able to perform? What helped them out? Which groups were not successfully able to perform? What problems did they run into? What do they think a computer or robot would do in that situation and how would they fix it?
Do you know what is a loop? How might it be used in programming?
Teaching Tips:
This section is talking about the different types of loops that can be programmed with Snap!. The types of loops and how to program them can be shown to the students using ClassView. In the main section that you and the students can see, an overview of the three types of loops is presented.
See below the answer to the question:
You have three programs that you need loops for. Which loop would you use for each program? Each type of loop is used only once. Discuss with your classmates:
- For playing your favorite song three times
The For loop is needed.
- For flying your CoDrone until the space key is hit
The Until loop is needed
- For keeping a digital clock running
The Forever loop is needed.
There are several types of loops that you can create with Snap!
1. Forever loop
Just like their name says, forever loops repeat the code within them forever. If you're suspicious about this, look at the bottom of the forever loop block. It's missing the connector at the bottom, so the code will never exit out of the loop and move on.
2. For loopFor loops repeat the code within them for an amount of time that you set. Once the code has been repeated for that amount of time, your program will exit out of the loop and move on to the rest of your code. The block in the program is called "Repeat".
3. Until loop
Until loops repeat until the condition you set in the diamond/hexagon-shaped space is true. Each time the program runs through the repeat until loop, it checks to see if the condition is true. If the condition is true, that doesn't mean the code automatically stops! The code stops when the condition is true AND when the code in the loop is finished. The bloc is called " Repeat Until".
You have three programs that you need loops for. Which loop would you use for each program? Each type of loop is used only once. Discuss with your classmates:
- For playing your favorite song three times
- For flying your CoDrone until the space key is hit
- For keeping a digital clock running
Teaching Tips:
- Ask students to use pseudocode to explain to a partner how they got their drone to move in a square or staircase pattern in Snap using both their own words and the appropriate academic language.
- Have students complete the Stair Challenge in the Loops in Flight lesson. For an extra challenge, have obstacles set up in ascending to descending height that the students will need to avoid. The students who successfully complete the challenge with the least amount of blocks win!
Challenge
Activity: Stair challenge
Make your CoDrone fly up a set of stairs (fly up, forward, up, forward, etc) and then fly back down!
Challenge rules:
- Use variables for delays.
- Use loops for any code that will be repeated more than once. Hint: you should have two loops in your program!
- Your CoDrone has to fly up at least three stairs.
- Your CoDrone needs to land!
Teaching Tips:
Have students answer the following questions to asses their understanding of the lesson. If there is time left, you can make students share their answers and experiences.