AP CSP CodeX - Mission 8: Answer Bot
Mission 8: Answer Bot
Students use lists and random numbers to program the CodeX to display random answers and colors.
Overview
This lesson introduces random numbers: different ways to generate them and use them in code. The mission includes a lot of code review, as well as new code. In Objective 5, students create a list of answers. After Objective 7, students practice their programming skills by creating a function, adding a kill switch, and clearing the screen and pixels at the end of the program.
🎯 Mission Goal: Students will use a list and a while loop to create a group of random answers.
Learning Targets
- I can create a list to use abstraction in my code.
- I can apply properties of lists in my program.
- I can use randomization with lists.
- I can create and call a function.
Key Concepts
- Random number generators are crucial for many computer applications.
- Lists can be used for a variety of purposes and uses in a program.
Assessment Opportunities
- Mission 8 Assignment
- Answer_Bot_obj7 program
- Answer_Bot_functions program
- Mission 8 Kahoot! Review
Success Criteria
- Program a button to print a random number
- Select a random item from a list and print it
-
Select a random color from
COLOR_LISTand use it to light up pixels - Create a function and call it in the main program
Digital Resources
- ▸Mission 8 Assignment
- ▸Code Solutions and Assignment Answers - Teacher Dashboard > Educator Resources button
- ▸Mission 8 Kahoot! Review
Classroom Materials
- ▸CodeX
- ▸USB-C cable
- ▸Computer
Real-World Applications
Extensions & Cross-Curricular
🔤
Vocabulary
▾
🐍
New Python Code
▾
scale. If the scale is too big, the text will appear as gibberish or shapes on the display screen. scale=1 is the default size.
📐
Standards
▾
CSTA Standards - Grades 9-10
CSTA Standards - Grades 11-12
AP CSP Framework
- 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.
- This lesson introduces random numbers: different ways to generate them and use them in code.
- The mission includes a lot of code review, as well as new code. Encourage students to do as much code on their own as they can, and use CodeTrek to check their work, or as a hint when needed.
- Objective 5 has students create a list. Encourage students to use their own lists, and not the one in CodeTrek. Also encourage them to have more than three items.
- After Objective 7, students will practice programming skills by creating a function, adding a kill switch, and clearing the screen and pixels at the end of the program. If students don't get all of the additions complete, that is okay. But they should try.
- An additional challenge is given for any students finishing the program and having extra time. It is not required, but good for extra practice with iteration, which is required for the Create PT.
- If you have time at the end of the lesson, use the Mission 8 Kahoot! Review.
- 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.
Use a discussion strategy, like journaling, working at boards, selecting random students, or a form of think-pair-share.
This is a project with practical applications. In our previous program, the programmer or the person running the program had control over when something happened or what image appeared. However, in real life and in computer applications, we might have a lot of randomness. What are some examples of when we need something randomized?
Discuss real-world applications:
- Video games
- Secure password encryption
- Real-world simulator trainers
- Scientific statistical sampling
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 computer.
Students go to make.firialabs.com and should be at the beginning of Mission 8.
display.print. I recommend using the keyword "parameter" so they become familiar with it. The instructions have them use scale=3. They can try different numbers for the scale. When the scale makes the text too big for the screen, it will turn into strange lines and not be readable. When this happens, they need to adjust the scale smaller.COLOR_LIST.display.clear() before the display.print() statement.display.clear() and pixels.off(). This code is NOT inside the while True: loop, or indented.Example solutions are given for the program as given in the mission, with additions, and with the challenge.
✅ The assignment is complete and ready to turn in.
Optional. Use a formative assessment for the wrap-up.
Formative assessment:
- Daily reflection journal
- Mission 8 Kahoot! Review (in class or individual)
- Exit ticket or group review on generating random numbers