AP CSP CodeX - Algorithms Lesson 3
Algorithms Lesson 3
Students trace robot code with repeat loops (iteration) to decide where the robot ends up.
Overview
This is an unplugged lesson, so students do not use computers. This lesson builds on Algorithms Lessons 1 and 2 by adding iteration. Working in partners or groups of three, students follow robot code with REPEAT loops and decide where the robot ends up. Students work through six code segments in the Activity Guide and choose the algorithms that give the correct result. Two additional problems are given as a challenge.
π― Mission Goal: Students will determine the result of code segments that have sequence, selection and iteration.
Learning Targets
- I can follow code with iteration to control a robot.
- I can evaluate multiple algorithms to determine which one leads to the correct result.
- I can evaluate multiple algorithms to determine if they yield the same result.
Key Concepts
- The AP CSP multiple choice exam will have questions that involve robot code. This lesson builds on the previous algorithms lesson by using code segments with iteration.
- The iteration will be a type of "repeat" statement. Python doesn't typically use a REPEAT statement.
- A REPEAT n TIMES is evaluated the same as a FOR loop.
- A REPEAT UNTIL (condition) is evaluated the same as a WHILE loop.
- A REPEAT FOREVER is evaluated the same as a WHILE TRUE loop.
- Students really need to pay attention to the type of REPEAT loop being used in the code.
Assessment Opportunities
- Algorithms Lesson 3 Activity Guide
- Review or test questions for algorithms
- Students compare their answers with each other and an answer key
- Daily reflection journal or Google Form, class discussion, or exit ticket
Success Criteria
- Evaluate iteration segments of robot code
- Select algorithms that accomplish the task
Digital Resources
Classroom Materials
- βΈPrinted Activity Guide (one per group)
- βΈPencil
- βΈOptional: sheets of paper to use as grid squares on the floor
Real-World Applications
Humans follow and use algorithms every day. Examples are:
Extensions & Cross-Curricular
π€
Vocabulary
βΎ
π
Standards
βΎ
CSTA Standards - Grades 9-10
CSTA Standards - Grades 11-12
AP CSP Framework
- Print the Activity Guide for each group. This lesson works better on paper than on a computer.
- Have sheets of paper ready if students will act out the code on a floor grid.
- Work the two example problems yourself before class. The answers are in the speaker notes of the slides.
- This lesson is best with partners or in groups of three.
- This lesson is better on paper than digitally. Print the assignment for each group.
- Make this lesson unplugged and physical! Most of the problems give one code segment and three scenes. This assignment is perfect for students acting out the code. Give students sheets of paper to use as squares on a grid. Lay out the squares on the floor and have one student be the robot and another student read the code. Physical activity is an excellent way to engage students and stimulate learning.
- Students do not need a computer for this lesson.
Lesson Outline
This outline gives one way to present the lesson.
Slides 2-4: Review the purpose of the activity and start the discussion on iteration.
π» Slides 5-7: These slides review the instructions from Lesson 1 and Lesson 2.
π» Slides 8-10: These slides give new instructions for evaluating a repeat loop (iteration) in the code. Two example problems are given. The answers are displayed in the speaker notes section.
Students do not need a computer for this activity; it is unplugged. Students work through the six code segment problems in the Activity Guide. Two additional problems are given as a challenge.
β The Activity Guide is complete and ready to turn in.
π» The Activity Guide doesn't include a wrap-up. The challenges can be used as a final activity.
β Formative assessment:
- Students compare their answers with each other and an answer key. You can require students to rework any missed problems.
- Daily reflection journal or Google Form
- Class discussion on what they learned during the activity
- Exit ticket