AP CSP CodeX - Algorithms Lesson 3

Algorithms Lesson 3 Lesson Plan

Algorithms Lesson 3

Students trace robot code with repeat loops (iteration) to decide where the robot ends up.

⏰ 45 min 🎯 Grades 9-12 πŸ“„ Unplugged
View Lesson Outline
πŸ“‹

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

β˜‘οΈ

Success Criteria

  • Evaluate iteration segments of robot code
  • Select algorithms that accomplish the task
🧰

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:

🍳Following a recipe.
🧭Driving and navigation.
πŸ—“οΈDaily routines.
πŸ—‚οΈOrganizing and sorting.
πŸš€

Extensions & Cross-Curricular

ExtensionStudents write one REPEAT n TIMES segment from the Activity Guide as a Python for loop, and one REPEAT UNTIL segment as a while loop, on paper, then check that each gives the same result.
MathStudents find the total number of squares the robot moves in a REPEAT n TIMES segment by multiplying the moves in one pass by n, then trace the code to check the answer.
Lang ArtsStudents explain in a few sentences the difference between REPEAT n TIMES, REPEAT UNTIL and REPEAT FOREVER, using one everyday example of each.
ScienceStudents look for repeating cycles in nature or machines, such as a heartbeat, the water cycle or a thermostat, and name what would make each one stop.
πŸ”€

Vocabulary

β–Ύ
Algorithm - A step-by-step process or set of rules for solving a problem.
Sequence - A programming structure where code runs line by line in order.
Selection - A programming structure using conditions to choose code paths (if/else).
Iteration - Repeating a block of code a set number of times or until a condition is met.
Efficiency - A measure of how much time or memory an algorithm uses as its input grows.
πŸ“

Standards

β–Ύ

CSTA Standards - Grades 9-10

3A-AP-13

CSTA Standards - Grades 11-12

3B-AP-10 3B-AP-11

AP CSP Framework

AAP-2.F - Evaluate expressions that use logic operators.
AAP-2.H - Determine the result of conditional statements.
AAP-2.I - Determine the result of nested conditional statements.
AAP-2.K - Determine the result or side effect of iteration statements.
Computational Thinking Practice 4.B - Determine the result of code segments.
πŸ“
Preparing for the Lesson
  • 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.

πŸ§‘β€πŸ«
Teacher Notes
  • 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.

πŸ—£οΈWarm-up

Slides 2-4: Review the purpose of the activity and start the discussion on iteration.

Teaching tip: All code segments in this lesson will use a form of iteration, or repeat loop. Review as necessary.
πŸ“–Instructions

πŸ’» 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.

Teaching tip: Have students work through the example on the Activity Guide. The answers aren't shown on a slide, but they are in the speaker notes. Students can compare their answers and make sure they get the correct answer before continuing. The correct answer for both examples is YES, the robot gets to delivery chute C.
✏️Robot Code Activities

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.

Teaching tip: Help students remember that turning left or right doesn't mean moving. The robot just turns in the square.

βœ… The Activity Guide is complete and ready to turn in.

πŸ§‘β€πŸ€β€πŸ§‘Wrap-Up

πŸ’» 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