Day 7 - Boolean Logic and Compound Conditions

Day 7: Boolean Logic and Compound Conditions

Learning Objectives

Essential Questions

Materials Needed

Vocabulary

Procedure (50 minutes)

Opening (8 minutes)

  1. Review and Connection (3 minutes)

    • Review basic conditional statements from previous lesson
    • Connect to today's focus on combining conditions
  2. Warm-up Activity (5 minutes)

    • Present a scenario requiring multiple conditions (e.g., eligibility for a program based on age AND education level)
    • Ask students how they might represent this decision in everyday language
    • Introduce the concept of compound conditions

Main Activities (32 minutes)

  1. Lecture: Boolean Expressions and Compound Conditions (12 minutes)

    • Review Boolean values (true and false) and relational operators
    • Introduce logical operators:
      • AND: true only when both conditions are true
      • OR: true when at least one condition is true
      • NOT: inverts a Boolean value
    • Explain the syntax for logical operators in the AP CSP pseudocode:
      • condition1 AND condition2
      • condition1 OR condition2
      • NOT condition
    • Demonstrate truth tables for each logical operator
    • Explain how to combine multiple conditions using logical operators
    • Discuss operator precedence in Boolean expressions
    • Show how parentheses can be used to control evaluation order
    • Explain common patterns and use cases for compound conditions
  2. Demo: Using AND, OR, NOT Operators (8 minutes)

    • Walk through examples of programs with compound conditions:
      • Checking if a number is within a range (min ≤ x AND x ≤ max)
      • Determining if a student passes (score ≥ 60 OR hasExtraCredit)
      • Validating complex input (NOT (age < 18) AND hasParentalConsent)
    • Show how to trace the evaluation of compound conditions
    • Demonstrate how different inputs affect condition evaluation
    • Highlight common mistakes in Boolean logic
  3. Hands-on: Writing and Evaluating Complex Conditions (12 minutes)

    • Students work in the programming environment
    • Guide students through creating programs with compound conditions
    • Have students implement programs for scenarios like:
      • Determining eligibility for a discount (senior OR student OR military)
      • Checking if a date is valid (validMonth AND validDay AND validYear)
      • Implementing game logic with multiple conditions
      • Creating a simple form validator
    • Encourage students to test their conditions with various inputs

Closing (10 minutes)

  1. Activity: Debugging Conditional Logic Errors (5 minutes)

    • Provide students with code segments containing logical errors
    • Students identify and fix the errors
    • Common errors might include:
      • Using AND when OR is needed (or vice versa)
      • Incorrect use of NOT
      • Missing parentheses affecting evaluation order
      • Redundant conditions
    • Discuss the fixes and reasoning
  2. Exit Ticket and Preview (5 minutes)

    • Students create a program that uses compound conditions to solve a problem
    • Preview that next class will focus on iteration (loops)

Assessment

Differentiation

For Advanced Students

For Struggling Students

Homework/Extension

Teacher Notes