AP CSP CodeX - Mission 9: Game Spinner
Mission 9: Game Spinner
Students use a list, functions, and while loops to animate the arrow of a game spinner on the CodeX.
Overview
During this mission, students animate a game spinner with custom functions. They use a logical operator to detect a press from either button, traverse a list of arrows, and learn techniques to avoid an index out of range error. After Objective 8, students use modulo division from the previous lesson to keep the index in range.
đ¯ Mission Goal: Students will use a list, functions and while loops to animate the arrow of a game spinner.
Learning Targets
- I can apply properties and uses of an index to a new program.
- I can define and call a function.
- I can utilize multiple variables in a new program and describe their purposes.
- I can utilize loops to make my code more efficient.
- I can create simulations using computer hardware and software.
Key Concepts
- Logical operators like 'and', 'or', and 'not' allow your code to test for multiple conditions.
- Define functions to break complex code into smaller, easy to use (and re-use) pieces.
-
Detect instantaneous button presses with
button.is_pressed() - Make your own animated sequences with loops and index variables.
-
Loop for a determined number of iterations:
while index < N
Assessment Opportunities
- Mission 9 Assignment
- Game_Spinner_modulo program
- Mission 9 Kahoot! Review
Success Criteria
- Display a random arrow from a list
- Detect a press from either BTN-A or BTN-B
- Use a loop to animate an arrow spinning
- Use a local variable to increase the number of loops
- Use a local variable to increase the length of the delay
- Use modulo division to keep the index in range
Digital Resources
- â¸Mission 9 Assignment
- â¸Code Solutions and Assignment Answers - Teacher Dashboard > Educator Resources button
- â¸Mission 9 Kahoot! Review
Classroom Materials
- â¸CodeX
- â¸USB-C cable
- â¸Computer
Real-World Applications
- Video games
- Flight simulators
- Virtual reality
Extensions & Cross-Curricular
random.randrange() to pick a different number of loops for each spin, so every spin lasts a different amount of time.
đ¤
Vocabulary
âž
đ
New Python Code
âž
đ
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 functions, but it will be mostly a review for your students.
- Encourage the 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.
- The assignment adds an extra step to complete after Objective 8, before turning in the program.
- Extensions are given in the teaching guide (but not the assignment) for any students finishing the program and having extra time.
- If you have time at the end of the lesson, use the Mission 9 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.
There isn't a specific warm-up for this lesson. As a teacher, decide on a topic that may need review with your students before starting the mission. You may want to review functions, or lists and indexes. Or you can go over common programming errors. Keep it to a quick review and then get right to the mission.
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 9.
Extensions for students who finish and have extra time (if the mission takes up the entire class period, skip these altogether):
- Add a "kill switch" to stop the loop and end the program.
- Add audio to the game spinner, something like a click or beep each time the arrow moves.
- Use one button to spin clockwise and another button to spin counterclockwise.
No example solutions are given for the extensions.
â The assignment is complete and ready to turn in.
Optional. Use a formative assessment for the wrap-up.
Formative assessment:
- Daily reflection journal
- Mission 9 Kahoot! Review (in class or individual)
- Exit ticket or group review on functions, local variables, or loop conditions