Day 2 - Variables and Assignments

Day 2: Variables and Assignments

Learning Objectives

Essential Questions

Materials Needed

Vocabulary

Procedure (50 minutes)

Opening (8 minutes)

  1. 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
  2. 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)

  1. 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
  2. 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
  3. 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)

  1. 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
  2. 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

Differentiation

For Advanced Students

For Struggling Students

Homework/Extension

Teacher Notes