AP CSP CodeX - Mission 7: Personal Billboard (Obj. 1-6)

Mission 7 Obj 1-6 Lesson Plan

Mission 7: Personal Billboard (Obj. 1-6)

Students program the CodeX buttons to scroll through a list of images, and use nested if statements to avoid an index out of range error.

⏰ 45 min 🎯 Grades 9-12 💻 CodeSpace 🎮 CodeX 🐍 Python
View Lesson Outline
📋

Overview

Mission 7 is divided into two lessons. In this first lesson (Objectives 1-6), students use the CodeX display and buttons to build a billboard that shows a mood, a fun picture, or an occasion. They program the buttons to select an image, scroll through a series of images in both directions, and use nested conditional statements to avoid an index out of range error. Then they store the images in a list, which makes it easy to add lots more. The Mission 7 Obj 1-6 Assignment guides students with notes and questions along the way.

🎯 Mission Goal: Students will use images to display a mood or occasion by pressing a CodeX button.

🎯

Learning Targets

  • I can create a list to make my code more efficient.
  • I can use if statements to scroll through a list.
  • I can use a nested if/else conditional statement to prevent an index out of range error.
💡

Key Concepts

  • In Python, == is used to compare two values for equality.
  • CodeSpace lets you inspect variables in the debugger.
  • A Python list is a powerful way to hold a collection of objects.
✅

Assessment Opportunities

☑️

Success Criteria

  • Program the buttons to select from a series of images to show
  • Create a list of images
  • Use conditional statements to scroll through a list
  • Use nested conditional statements to avoid index out of range errors
  • Change the code to make it easy to add more images and items to a list
📁

Digital Resources

🧰

Classroom Materials

  • ▸CodeX
  • ▸USB-C cable
  • ▸Computer
🌍

Real-World Applications

🪧Have you ever made a sign for a door or wall, worn a name badge, or worn a cap or t-shirt with a message on it? Students build a device that displays images or text, and use the CodeX buttons to select what is shown to suit a particular occasion or mood.
🎉Imagine everyone at a party or meeting wearing CodeX badges that show their name and interests. Or a cap for a sports team, given out to all the fans before a big game.
📋Software of all kinds, like menu systems on websites and in video games, works with lists or collections of data. The code students learn in this project has thousands of real-world applications.
🚀

Extensions & Cross-Curricular

ExtensionInstead of button presses, have the selections advance on their own. The list could be animation sequences, or the set list for a band.
ExtensionStudents trade programs with a partner and try to break each other's billboard by scrolling past the first and last image in both directions.
MathStudents explain why the last index of a list is one less than its length, using a list of five images (indexes 0 to 4).
Lang ArtsStudents pick a mood or occasion, choose images that fit it, and write a sentence explaining why each image belongs on their billboard.
🔤

Vocabulary

▾
Comparison operator - Operators that let you compare two values. The result is True or False. Comparison operators include: ==, <, >, <=, >=, !=
Nested condition - Another if statement that is part of (embedded in) the block of code in an if statement. In other words, an if statement within an if statement.
List - A sequence of items you can access with an index.
Index - A number that keeps track of what choice should be displayed.
Data abstraction - The process of hiding details and showing only essential information to the user. A list is a form of data abstraction because it gives a sequence of items a name that all items can then be referenced with.
🐍

New Python Code

▾
if choice == 0: # do something - block of codeCompare a variable to a specific value. Is it the same?
LAST_INDEX = len(my_list) - 1The last index of a list (one less than the length of the list). LAST_INDEX is a constant. Its value does not change, so it is written in ALL CAPS.
if buttons.was_pressed(BTN_L): choice = choice - 1 if choice < 0: choice = LAST_INDEXAn example of a nested if statement. The list index wraps around to the other end of the list.
my_list = [pics.HAPPY, pics.SAD, pics.SURPRISED, pics.ASLEEP]Define a list. The items in the list can be on the same line, or divided between lines. The spaces and new lines are ignored by the computer. Each item is separated with a comma (,).
my_item = my_list[2] index = 3 my_item = my_list[index]Examples of accessing an item from a list. Use a literal number for the index, or a variable for the index.
📐

Standards

▾

CSTA Standards - Grades 9-10

3A-CS-01 3A-CS-03 3A-AP-13 3A-AP-14 3A-AP-15 3A-AP-16 3A-AP-17 3A-AP-18

CSTA Standards - Grades 11-12

3B-CS-02 3B-AP-10 3B-AP-12 3B-AP-14 3B-AP-16 3B-AP-21 3B-AP-23

AP CSP Framework - Learning Objectives

AAP-1.C - Represent a list or string using a variable.
AAP-1.D - Develop data abstraction using lists to store multiple elements, and explain how the use of data abstraction manages complexity in program code.
AAP-2.I - Write nested conditional statements, and determine the result of nested conditional statements.
AAP-2.N - Write expressions that use list indexing and list procedures.

AP CSP Framework - Computational Thinking Practices

3.A - Generalize data sources through variables.
3.B - Use abstraction to manage complexity in a program.
📝
Preparing for the Lesson
  • The assignment is best completed digitally. Prepare the assignment to give through your LMS.
  • If you have a word wall, or another form of vocabulary presentation, prepare the new terms.
  • Have the Mission 7 Kahoot! Review ready in case you have time at the end of the lesson.

🧑‍🏫
Teacher Notes
  • Mission 7 may take a little over a class period, so it is divided into two lessons. This page covers Objectives 1-6.
  • Objective 4 introduces the term "nested condition," which is not specifically mentioned in the CodeSpace instructions, but it is a topic covered on the AP exam. You may want to emphasize this.
  • Objective 6 introduces the term "data abstraction," which is not specifically mentioned in the CodeSpace instructions, but it is a topic covered on the AP exam. You may want to emphasize this.
  • After Objective 6 and the quiz, students continue the assignment by adding more than five items to their list. Here is a list of all the built-in images:
  • pics.HEART
  • pics.HEART_SMALL
  • pics.MUSIC
  • pics.HAPPY
  • pics.SAD
  • pics.SURPRISED
  • pics.ASLEEP
  • pics.TARGET
  • pics.TSHIRT
  • pics.PLANE
  • pics.HOUSE
  • pics.TIARA
  • pics.ARROW_N
  • pics.ARROW_NE
  • pics.ARROW_E
  • pics.ARROW_SE
  • pics.ARROW_S
  • pics.ARROW_SW
  • pics.ARROW_W
  • pics.ARROW_NW
  • If you have time at the end of the lesson, use the Mission 7 Kahoot! Review. All questions on the review are covered in the first 6 objectives.
  • Refer to the lesson plans in the Python with CodeX Mission Pack Curriculum for additional challenges, cross-curricular suggestions, and additional information.
🗺️

Lesson Outline

This outline gives the narration for one way to present the lesson.

🗣️Warm-up

Use a discussion strategy, like journaling, working at boards, selecting random students, or a form of think-pair-share.

Topic: Ask students about lists. What are some lists you use in everyday life (playlist, contact list, grocery list, to-do list, etc.)? When might you want to use a list in a program?

💻Activity - Mission 7 Objectives 1-6

Randomly group students into pairs for pair programming (or they can work individually).

Students log in to one computer. Two computers can be used if they want to have the activity guide open on one computer and CodeSpace on the other.

Students go to make.firialabs.com and should be at the beginning of Mission 7.

Teaching tip - Objective 1: This objective is mostly review. Challenge students to complete the program code on their own and check it with CodeTrek.
Teaching tip - Objective 2: Students can use CodeTrek if needed. Still, they will need to add new code on their own. They should have four if statements with choice and another if statement for a button press to complete the objective.
Teaching tip - Objective 3: Students will add another if statement for a button push. They will also open the CONSOLE. There is an animation in the instructions that shows them where to find the console. You should be familiar with this so you can assist as needed. They are also asked to use the debugger. They may need a reminder about what to do with the debugger.
Teaching tip - Objective 4: Students use nested conditional statements in this objective. Call out or mention the term used for this so they are familiar with it for the AP exam.
Teaching tip - Objective 5: This is the first introduction to using a list.
Teaching tip - Objective 6: Students learn a lot more about lists in this objective. A future lesson will have them practice these concepts even more in an unplugged activity.
Teaching tip - After Objective 6: A list is a form of data abstraction, which they need to know for the AP exam. You should emphasize this term and talk a little about data abstraction and how it manages complexity in a program. Exam questions and written response prompts may use the term "data abstraction."
Teaching tip - After Objective 6: Students will add more items to the list, just to get experience with using a list and how the list functions work and manage complexity.

✅ The assignment is complete and ready to turn in. You can decide if you want students to turn in the program up to this point, or wait until the end of Mission 7.

🧑‍🤝‍🧑Wrap-Up

Use a formative assessment for the wrap-up.

Formative assessment:

  • Daily reflection journal
  • Mission 7 Kahoot! Review (in class or individual). All questions can be answered during Objectives 1-6.
  • Exit ticket on lists or nested if statements
  • Group review on lists or nested if statements