Day 2 - Variables and Assignments
Day 2: Variables and Assignments
Learning Objectives
- AAP-1.A: Represent a value with a variable.
- AAP-1.B: Determine the value of a variable as a result of an assignment.
- AAP-1.C: Represent a list or string using a variable.
Essential Questions
- How do computers store and manipulate data?
- How do variables help us represent and work with data in programs?
Materials Needed
- Presentation slides on variables and assignments
- Programming environment (block-based or text-based)
- Variable practice worksheet
- Exit ticket templates
- Sticky notes for concept check
Vocabulary
- Variable
- Assignment
- Data type
- Integer
- String
- Boolean
- List
- Declaration
- Initialization
Procedure (50 minutes)
Opening (8 minutes)
-
Review and Connection (3 minutes)
- Review algorithm concepts from previous lesson
- Connect to today's focus on variables as a way to store data in programs
-
Warm-up Activity (5 minutes)
- Display a simple program with variables and ask students to predict what it does
- Discuss initial thoughts about how the computer keeps track of values
Main Activities (32 minutes)
-
Lecture: Variables, Data Types, and Assignments (12 minutes)
- Define variables as abstractions that hold values in a program
- Explain different data types:
- Numbers (integers, decimals)
- Strings (text)
- Booleans (true/false)
- Lists (collections of values)
- Demonstrate variable declaration and assignment
- Explain the assignment operator (←) and how it works
- Discuss the importance of meaningful variable names
- Show how the same variable can hold different values over time
-
Demo: How Variables Store and Update Values (8 minutes)
- Use a visual representation of memory to show how variables work
- Demonstrate step-by-step execution of code with variable assignments
- Show examples of:
- Simple assignment (a ← 5)
- Assignment from another variable (b ← a)
- Reassignment (a ← 7)
- Assignment with expressions (c ← a + b)
- Emphasize that variables hold the most recent value assigned
-
Hands-on: Declaring Variables and Assigning Values (12 minutes)
- Students work in the programming environment
- Guide students through creating variables of different types
- Have students write and test code with variable assignments
- Students trace code execution and predict final variable values
- Include examples with multiple assignments and expressions
Closing (10 minutes)
-
Activity: Trace Code with Variable Assignments (5 minutes)
- Provide students with a code segment containing multiple variable assignments
- Students trace the code step by step, recording the value of each variable after each statement
- Discuss the final values and any common misconceptions
-
Exit Ticket and Preview (5 minutes)
- Students complete exercises involving variable declarations and assignments
- Preview that next class will focus on expressions and operators
Assessment
- Formative: Participation in hands-on activities and code tracing
- Exit Ticket: Accuracy of variable assignment exercises
Differentiation
For Advanced Students
- Provide more complex assignment scenarios
- Introduce additional data types or type conversion
- Challenge them to create a program that uses multiple variable types
For Struggling Students
- Provide a visual reference for how assignment works
- Use simpler examples with fewer variables
- Offer a step-by-step template for tracing code
Homework/Extension
- Complete a worksheet with variable declaration and assignment exercises
- Write a short program that uses variables to store and manipulate personal data (age, name, etc.)
- Research how different programming languages handle variable declarations and types
Teacher Notes
- Emphasize that variables in memory are different from variables in algebra
- Watch for confusion about the assignment operator (← is not the same as = in mathematics)
- Make connections to how variables will be used in future programming tasks
- Consider using physical props (boxes with labels) to demonstrate variable concepts
- Remind students that understanding variables is fundamental to all programming