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

Mission 7 Obj 7-9 Lesson Plan

Mission 7: Personal Billboard (Obj. 7-9)

Students mix images, text, and colors in a list and use type() to display each one with the CodeX buttons.

โฐ 45 min ๐ŸŽฏ Grades 9-12 ๐Ÿ’ป CodeSpace ๐ŸŽฎ CodeX ๐Ÿ Python
View Lesson Outline
๐Ÿ“‹

Overview

Mission 7 may take a little over a class period, so it is divided into two lessons. This lesson covers Objectives 7-9. Students add a text string to their billboard list, then add a color and see the error it causes. They fix the error by using type() to check each item and display.fill() to fill the screen with a color. After Objective 9, students practice by adding colors as tuples, creating and calling functions, and programming a kill switch.

๐ŸŽฏ Mission Goal: Students will use images, text, and colors in a list to display a mood by pressing a CodeX button.

๐ŸŽฏ

Learning Targets

  • I can distinguish between string and image data types.
  • I can use type() to check the data type of an item and handle it accordingly.
  • I can use existing code to create a function.
๐Ÿ’ก

Key Concepts

  • In Python, == is used to compare for equality.
  • You can check the type of a variable and deal with it accordingly.
  • The type() function returns the data type of its argument. It can be used in the Console and in a program.
โœ…

Assessment Opportunities

โ˜‘๏ธ

Success Criteria

  • Mix text messages with a selection of images and color
  • Use existing code to create a function
๐Ÿ“

Digital Resources

๐Ÿงฐ

Classroom Materials

  • โ–ธCodeX
  • โ–ธUSB-C cable
  • โ–ธComputer
๐ŸŒ

Real-World Applications

๐ŸชงHave you ever made a sign to post on a door or wall? How about a name badge to wear, or a cap or t-shirt with a message or slogan on it? In this project, students build a device that lets them display images or text, and use the CodeX buttons to select what is shown to suit a particular occasion or mood.
๐ŸงขImagine if everyone at a party or meeting wore CodeX badges like this to show their name and interests. Or what if you made this into a cap for a sports team, to give out to all the fans before a big game?
๐Ÿ“‹Have you ever scrolled through a menu on a website or in a video game? Software of all kinds deals with lists or collections of different types of data. The code students learn in this project has thousands of real-world applications.
๐Ÿš€

Extensions & Cross-Curricular

ExtensionStudents who finish early add a function that introduces the program and explains how to scroll the list. It waits for a button press, then clears the screen and starts the main program. This is a good feature to practice for the AP Create PT.
ExtensionMake the selections advance on their own instead of waiting for button presses. The list could be animation sequences, or the set list for a band.
Lang ArtsStudents write the messages for their billboard for a specific audience or occasion, such as a name badge, a team cap, or a party, and explain why they chose each one.
MathColors in the codex library are tuples of three integers: (red, green, blue). Students predict the color for a tuple such as (0, 0, 255), then test it with display.fill() and compare.
๐Ÿ

New Python Code

โ–พ
type(7)In the Console, returns <class 'int'>
type(1.15)In the Console, returns <class 'float'>
my_type = type(7)Get the data type of a variable. You can do this in the Console panel or in the code itself.
if type(my_image) == tuple:Use the data type in a branch to decide how to handle an item.
display.fill(RED)Fill the display screen with a color.
display.fill(my_color)Fill the display screen with the color stored in a variable.
๐Ÿ“

Standards

โ–พ

CSTA Standards - Grades 9-10

3A-CS-01 3A-CS-03 3A-DA-09 3A-AP-13 3A-AP-14 3A-AP-15 3A-AP-16 3A-AP-17 3A-AP-18 3A-AP-21 3A-IC-26

CSTA Standards - Grades 11-12

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

AP CSP Framework

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.
Computational Thinking Practice 3.A - Generalize data sources through variables.
Computational Thinking Practice 3.B - Use abstraction to manage complexity in a program.
๐Ÿ“
Preparing for the Lesson
  • In advance, create a class on your dashboard and have the join code ready to give your students.
  • The assignment is best completed digitally. Prepare the assignment to give through your LMS.
  • Students need the Billboard program from the Mission 7 Obj 1-6 lesson.

๐Ÿง‘โ€๐Ÿซ
Teacher Notes
  • Mission 7 may take a little over a class period, so it is divided into two lessons.
  • Objective 7 introduces strings. You can spend some time on what a string is and how to create one. A string is a type of list, and list functions also work with a string.
  • The code in Objective 8 will cause an error. This should happen! It is fixed in the next objective.
  • Objective 9 fixes the type error. Students should click the term "error" and read about it in the Toolbox. It lists several errors that can occur in a Python program. This is good information for programming in general and the AP exam specifically.
  • After Objective 9, students practice programming skills by adding colors in the form of a tuple, creating and calling functions, and programming a kill switch. Use the time you have, but if all additions aren't included, that is okay.
  • An additional challenge is given for students who finish the program and have extra time. It is not required, but it is a nice feature of programming, and something they can do for the AP Create PT.
  • 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: Review what students have learned so far in Mission 7. You can also review what students learned about RGB colors.

๐Ÿ’ปActivity - Mission 7 Objectives 7-9

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 in Mission 7 at Objective 7. Open the Billboard program.

Teaching tip - Objective 7: Students learn about strings and add them to the list. The structure of the list needs to be maintained. The string element is in quotation marks, and the comma (,) separating the items is outside the quote marks.
Teaching tip - Objective 8: The code will result in an error. Expect it! The error is fixed in the next objective.
Teaching tip - Objective 9: Students learn about errors, and then fix the type error caused in Objective 8. You can spend some time discussing the other errors and what might cause them.

You can decide if you want students to turn in their code at this point. The "After Objective 9" activity is optional, but it is really good practice for the Create PT. If you have class time to do it, we recommend it. If you are short on time, or if some of your students work at a slower pace, you can skip it.

๐Ÿ› ๏ธActivity - After Objective 9
Teaching tip - After Objective 9: With this activity, students have a chance to practice some of the programming skills they have been learning. Spend the time you have on these additions. If students don't do them all, that is okay.
  • First, RGB colors. Have students add colors to their list using RGB triplets (tuples).
  • Second, functions. Have students create at least one function from their program code. The easiest function to create is for displaying the item in the list. Another function could be for changing the choice. This function requires the global choice line of code. Both functions are similar to the extra code completed in the program for Mission 6 (Heartbeat_functions).
  • Third, kill switch. Students learned that a break statement stops the loop. Students can add another if statement to the main program using a different button.
  • Fourth, clear the display. After the while loop ends, use display.fill(BLACK) to clear the screen.

As an added challenge for highly motivated students, see if they can create a third function that is an introduction. It will display first, and give instructions on what to do.

Example solutions are given for this activity and the challenge.

โœ… The assignment is complete and ready to turn in.

๐Ÿง‘โ€๐Ÿคโ€๐Ÿง‘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