AP CSP CodeX - Algorithms Lesson 2

Algorithms Lesson 2 Lesson Plan

Algorithms Lesson 2

Students trace robot code that uses selection (CAN_MOVE) 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 Lesson 1 by adding selection. Working in partners or groups of three, students follow robot code that asks a yes or no CAN_MOVE question, then decide if the robot gets the diamond, misses it, or crashes. Students work through eight code segments in the Activity Guide, each with three scenes, and choose the algorithms that give the correct result.

🎯 Mission Goal: Students will determine the result of code segments that have sequence and selection.

🎯

Learning Targets

  • I can follow code with selection 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 selection.
  • The selection will be CAN_MOVE statements with a direction. This is a "yes" or "no" question. If yes, continue, if no, skip.
  • Students can make a little paper robot and label left and right to help them evaluate the code.
βœ…

Assessment Opportunities

  • Algorithms Lesson 2 Activity Guide
  • Wrap-Up programs and grids that students create (optional)
  • 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 selection segments of robot code
  • Select algorithms that accomplish the task
🧰

Classroom Materials

  • β–ΈPrinted Activity Guide (one per group)
  • β–ΈPencil
  • β–ΈPaper to make a little paper robot
  • β–Έ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 take one code segment from the Activity Guide and change the condition or direction so the robot crashes in a scene where it was safe, then explain what the change did.
MathStudents make a table of each scene with the yes or no answer to the CAN_MOVE question and the final square, then look for patterns in how a yes or no changes the outcome.
Lang ArtsStudents write an if/else rule for an everyday choice, such as "if it is raining, take an umbrella, otherwise wear sunglasses", and identify the condition in each rule.
ScienceStudents name a real machine that checks its surroundings before it moves, such as a robot vacuum or an automatic door, and describe the yes or no question it asks.
πŸ”€

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).
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.H - Determine the result of conditional statements.
AAP-2.I - Determine the result of nested conditional statements.
Computational Thinking Practice 4.B - Determine the result of code segments.
Computational Thinking Practice 4.C - Identify and correct errors in algorithms and programs, including error discovery through testing.
πŸ“
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.
  • Have paper ready for students to make a little paper robot and label its left and right.
  • Work the example problem on the Activity Guide yourself before class. The answer is not shown on a slide.

πŸ§‘β€πŸ«
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-3: Review the purpose of the activity.

Teaching tip: All code segments in this lesson will use a form of if/else statement. Review as necessary.
πŸ“–Instructions

πŸ’» Slides 4-6: These slides review the instructions from Lesson 1.

πŸ’» Slides 7-9: These slides give new instructions for evaluating a condition (selection) in the code. An example problem is given.

Teaching tip: Have students work through the example on the Activity Guide. The answer isn't shown on a slide. Students can compare their answers and make sure they get the correct answer before continuing. The correct answer is A. C1

πŸ’» Slide 10: This slide gives specific information for the remaining problems in the Activity Guide. Each problem has one code segment and three different scenarios.

πŸ’» Slides 11-13: Sample problem, not on the Activity Guide. The problem has one code segment and three different scenarios.

Teaching tip: Students should work through each scenario and determine if the robot gets the diamond, misses the diamond or crashes. Answers are not given on the slides. They are:
  • Scene #1: misses the diamond (is in front but not on the diamond)
  • Scene #2: crashes!
  • Scene #3: gets the diamond
✏️Robot Code Activities

Students do not need a computer for this activity; it is unplugged. Students work through the eight code segment problems in the Activity Guide.

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 includes a wrap-up where students create their own programs and grids. This can be omitted if time does not permit, but it is a fun way for students to be engaged in their learning.

βœ… 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