Lesson 25: For Loops in Bee
Overview
Featuring Bee, this lesson focuses on for
loops and using an incrementing variable to solve more complicated puzzles. Students will begin by reviewing loops from previous lessons, then they'll walk through an introduction to for
loops so they can more effectively solve complicated problems.
Purpose
Today's concept, for
loops, are a very important topic in computer science. Not only are they widely used, the process of learning for
loops enhances the learning of other important concepts (such as variables and parameters.) Students will have plenty of practice critically thinking through problems by determining the starting, ending, and stepping values for each for
loop. This concept uses plenty of math as well, so feel free to pair it with a math lesson for an even deeper learning experience.
Agenda
Warm Up (15 min)
Bridging Activity - For Loops (15 min)
Main Activity (30 min)
Wrap Up (15 min)
View on Code Studio
Objectives
Students will be able to:
- Determine starting value, stopping value, and stepping value for a `for` loop.
- Recognize when to use a `for` loop and when to use other loops such as `repeat` and `while` loops.
Preparation
- Play through the CSF Express Course - Website associated with this lesson to find any potential problem areas for your class.
- Review CS Fundamentals Main Activity Tips - Lesson Recommendations.
- Make sure every student has a Think Spot Journal - Reflection Journal.
Links
Heads Up! Please make a copy of any documents you plan to share with students.
For the Teachers
- CSF Express Course - Website
- CS Fundamentals Main Activity Tips - Lesson Recommendations
For the Students
- Unplugged Blocks (Courses C-F) - Manipulatives
- Think Spot Journal - Reflection Journal
Vocabulary
- For Loop - Loops that have a predetermined beginning, end, and increment (step interval).
Support
Report a Bug
Teaching Guide
Warm Up (15 min)
Introduction
Remind students of the work they did in "For Loop Fun". Open a discussion about what they learned, why they think it might be useful, and if they had any fun. Here are some discussion starters.
- What did you learn in "For Loop Fun"?
- What are the three main components of a
for
loop?- starting value, step interval, ending value
- Why do you think a
for
loop might be helpful in programming?- Many students might not know an answer to this. Let them hypothesize, but don't dwell on this question for too long.
- Did you have fun learning about
for
loops? Why or why not? - Are you excited to use
for
loops in online puzzles?
Bridging Activity - For Loops (15 min)
This activity will help bring the unplugged concepts from "For Loop Fun" into the online world that the students are moving into. Choose one of the following to do with your class:
Unplugged Activity Using Paper Blocks
Split up the students of your class into pairs. Ideally have the pairs be the same from when your class did "For Loop Fun". Print out a for
loop from Unplugged Blocks (Courses C-F) - Manipulatives for each pair of students. Pass out one die to each pair. Have the partners take turns rolling the die to obtain the following values:
- One roll for the starting value
- Four rolls for the ending value
- One roll for the step value
Have each pair fill in the for
loop with the appropriate values in the correct spot.
Using a basic number line, like the one used in "For Loop Fun", have the students mark the beginning, ending, and middle values that this for
loop will touch. When everyone is done, see who got the most points by totaling the starting, middle, and ending numbers of each pair.
Previewing Online Puzzles as a Class
Display a puzzle from the Course F Online Puzzles - 2018 - Website associated with this lesson. We recommend puzzle #4 because it displays a potential solution and asks the user to evaluate it.
Using a number line similar to the ones used in "For Loop Fun", mark the start and ending values of the given for
loop (if you aren't using puzzle #4, you will need to come up with a potential solution first). With the class's help, circle the values between the start and end that the for
loop will touch. If you are working on puzzle #4, ask the class what they think the answer is to the question, given what they found with the number line.
Main Activity (30 min)
CSF Express Course - Website
Some students may have a hard time differentiating between repeat
loops and for
loops. We recommend having scratch paper out for students to make guesses on values like the start, stop, and step. Implementing pair programming amongst the class might also be helpful for your students.
Wrap Up (15 min)
Journaling
Having students write about what they learned, why it’s useful, and how they feel about it can help solidify any knowledge they obtained today and build a review sheet for them to look to in the future.
Journal Prompts:
Standards Alignment
View full course alignment
CSTA K-12 Computer Science Standards (2017)
AP - Algorithms & Programming
- 1B-AP-09 - Create programs that use variables to store and modify data.
- 1B-AP-11 - Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process.