AP CSP CodeX - Mission 4: Display Games (Obj. 8-10) & Functions

Mission 4 Obj 8-10 & Functions Lesson Plan

Display Games (Obj. 8-10) & Functions

Students program CodeX buttons to get input from the user, then use if:else statements and functions to build a game.

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

Overview

This is the second part of Mission 4. Students finish the last objectives of Display Games, then extend their Display program with functions. The Mission 4 Obj 8-10 & Functions Assignment guides them through both parts and ends with the code they turn in.

🎯 Mission Goal: Students will program CodeX to get input from the user by pressing buttons to create a game.

🎯

Learning Targets

  • I can program buttons to determine whether they are pressed.
  • I can write an if:else conditional statement.
  • I can create and use functions as a form of procedural abstraction.
💡

Key Concepts

  • Indenting after a colon is very important!
  • Branching allows segments of code to run when a condition is True, and other segments of code to run when the condition is False.
  • Functions can be used as procedural abstraction to hide details and focus on specific tasks.
✅

Assessment Opportunities

☑️

Success Criteria

  • Get input from pressing a button
  • Use a branching if:else statement with a Boolean variable
  • Create a function for each button press
  • Call the functions in a specific order to create a game
📁

Digital Resources

🧰

Classroom Materials

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

Real-World Applications

The skills used in this project are used by professional software developers to build:

🚦Traffic lights
🏟️Sports event scoreboards
🎮Games
🗣️The mission controls lights, displays images and text, and accepts input from the user through a button press. Discuss devices that do this in our daily lives.
🚀

Extensions & Cross-Curricular

ExtensionFill the screen with red or green (or add a short delay) in addition to changing a pixel.
ExtensionAdd an image at the end of the game.
ExtensionInstead of lighting a pixel, display a message of "Right" or "Wrong".
ExtensionExtend the game to more than 4 questions.
ExtensionAdd a function for turning off all pixels and clearing the screen, and call it at the end of the program.
Lang ArtsStudents keep a daily journal, or use a reflection form, to process what they learned and write down questions they still have.
🔤

Vocabulary

▾
Procedural Abstraction - A technique that breaks down complex tasks into smaller, more manageable procedures.
🐍

New Python Code

▾
pressed = buttons.is_pressed(BTN_A)Assign True or False to a variable. Checks if the button is currently pressed.
pressed = buttons.was_pressed(BTN_A)Assign True or False to a variable. Checks if the button was pressed since the last check.
📐

Standards

▾

CSTA Standards - Grades 9-10

3A-CS-03 3A-AP-13 3A-AP-16 3A-AP-21

CSTA Standards - Grades 11-12

3B-AP-16 3B-AP-17 3B-AP-21 3B-AP-22 3B-AP-23

AP CSP Framework - Learning Objectives

AAP-2.H - Write conditional statements. Determine the result of conditional statements.
AAP-3.A - Write statements to call procedures.
AAP-3.B - Explain how the use of procedural abstraction manages complexity in a program.
AAP-3.C - Develop procedural abstractions to manage complexity in a program by writing procedures.

AP CSP Framework - Computational Thinking Practices

3.B - Use abstraction to manage complexity in a program.
3.C - Explain how abstraction manages complexity.
📝
Preparing for the Lesson
  • Have the Mission 4 Functions slides ready. You can show them on a big screen, or have students follow along on their computers.
  • Decide whether students will work individually, keep their partner from Mission 4 Obj 1-7, or get new partners.
  • If you have a word wall, or another form of vocabulary presentation, prepare the new term: procedural abstraction.

🧑‍🏫
Teacher Notes
  • This is the second part of Mission 4, and it includes additional instructions for creating and using procedures.
  • The second half of the assignment starts after the objectives are completed. Open the slides, or have students work through the slides, to create and use functions in the program.
  • Students should keep the Display program open for the second half, and save it with a new name when following the instructions on the slides.
  • Students should use the Sandbox for the added instructions. However, if they stay in Mission 4 Objective 10, that is okay.
  • Another suggestion for assessment is for students to keep a daily journal, or use a reflection form for students to process information they learned and reflect on questions they may still have.
  • You may consider having students (or the class collectively) keep a chart of errors and the ways to fix them.
  • You can also add vocabulary to a word wall and keep a document or chart of the Python code learned during each mission.
  • 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.

Review with students the concepts from Mission 4 completed in the last lesson:

  • Assigning a value to a variable using math
  • Boolean variables
  • Branching
  • Indenting
💻Activity - Mission 4 Objectives 8-10

Students can get new partners for pair programming, or continue to work with the same partner they had with Mission 4 Obj 1-7. Or they can work individually.

If students are working with a partner, students log in to one computer. Two computers can be used if they want to have the activity guide and slides open on one computer and CodeSpace on the other computer.

Students go to make.firialabs.com and should be on Objective 8 of Mission 4.

Teaching tip - Objective 8: This objective does not need the CodeX. Students use the 3D simulator to identify the 6 CodeX buttons.
Teaching tip - Objective 9: Students have a question to answer on the activity guide.
Teaching tip - Objective 10: CodeTrek shows code for two of the buttons. Students can choose any two buttons they want. They can even use the same button twice. Then they write code for two more buttons. At this point the instructions in CodeSpace are complete. You can have students turn in the code at this point for assessment, if you want.
⚙️Activity - Mission 4 Functions

Students continue working with a partner or individually.

The Mission 4 Functions slides are needed for the rest of the lesson. You can show the slides on a big screen, or have students follow the slides on their computers.

Teaching tip - Slides 1-6: Review functions and abstraction, with an emphasis on procedural abstraction. Students answer questions in the activity guide.
Teaching tip - Slides 7-14: Students save the Mission 4 program Display with a new name: Display_functions. Then they follow the instructions on slides 7-14 to modify their code using functions. Students should use the Sandbox for this part of the lesson, but if they stay in Mission 4 Objective 10 that will work fine, too. This part of the lesson reinforces the concepts learned and used in "Defining Functions" after Mission 3.

If students have time, some extension ideas are given to keep students engaged and applying their knowledge. All are optional, but a great opportunity for student learning.

✅ The assignment is complete and ready to turn in. Both students should include their names on the document. Students should turn in their completed program.

🧑‍🤝‍🧑Wrap-Up

Formative assessment:

  • Daily reflection journal
  • Mission 4 Kahoot Review
  • Exit ticket on procedural abstraction
  • Group or class discussion on what they learned in the lesson