Lesson 2.5: Combining Variables
Learning Objectives
Students will be able to...
- Combine loops with conditionals to create models with repeated but conditional behavior
Materials/Preparation
Pacing Guide
Duration | Description |
---|---|
5 minutes | Welcome, attendance, bell work, announcements |
10 minutes | Review, lecture and introduce activity |
30 minutes | Gravity activity |
10 minutes | Review and wrap-up |
Instructor's Notes
- Review and lecture
- Review loops and conditionals
- Ask students what loops do, when they are useful, and what loops exist in SNAP
- loops cause code to execute multiple times
- loops can help reduce redundancy and increase readability
- SNAP contains three loops: repeat, forever, and repeat until
- Ask students what conditionals are for and when they are useful
- conditionals are used to execute a block of code only under certain circumstances
- Encourage discussion about previous activities
- Fill in understanding gaps when necessary
- Ask students what loops do, when they are useful, and what loops exist in SNAP
- Demonstrate combining loops and conditionals
- Present
and
- Ask students to suggest when these constructs might be useful
- "repeat until" is useful when a loop needs to run not for a set number of iterations, but until some situation occurs
- "forever if" is useful when code should execute any time a condition is true, for the duration of the program
- Point out that the condition in "repeat until" is a termination condition, while in "forever-if" it is a continuation condition
- Present
- Introduce the concept of modeling
- modeling: building a system to simulate the behavior of a real-life phenomenon by simplifying or ignoring certain details
- Ask students to suggest systems or concepts that might need to be modeled
- Discuss important considerations when designing and implementing a model
- Lead students to realize that most sacrifice some amount of accuracy or realism for simplicity
- Review loops and conditionals
- Activity
- Students should complete "What Goes Up..." lab individually
- Mention that the code written in this lab will be helpful for the Platform Game project
- Students should complete "What Goes Up..." lab individually
- Debrief
Accommodations/Differentiation
- Take care to ensure that all students have functional code by the end of the lab to avoid putting some students at a disadvantage starting the project
- If many students struggle, consider releasing your own solution after the lab has been completed in class
- Utilize TAs and advanced students to assist struggling students—it is vital that all students complete this lab in advance of starting the project
- Advanced students can consider increasing the realism of their gravity model by adding acceleration and/or beginning to implement jumping