1. Reference Guide

Key Vocabulary

Term Definition Example
Boolean A value that is either True or False. is_valid = True
Boolean expression An expression that evaluates to True or False. count > 0
Relational operator Compares two values. ==, !=, >, <, >=, <=
Logical operator Combines or reverses Boolean values. and, or, not
Compound expression A Boolean expression with multiple conditions. has_name and not duplicate
Validation Checking whether data satisfies required rules. approve/reject an SFI record

Truth Guide

A B A and B A or B
True True True True
True False False True
False True False True
False False False False

not True is False, and not False is True.

Translating English Rules

  • All requirements must pass β†’ use and.
  • Either option is acceptable β†’ use or.
  • Reject a duplicate β†’ often use not duplicate.
  • Break a long rule into named Boolean variables before combining it.
  • Test valid, invalid, and edge cases instead of checking only one record.

2. LxD Cycle Process

Empathize: Boolean expressions look simple because every result is only True or False, but students often mix up assignment and comparison, reverse an and/or rule, or test only one case and assume the condition is correct.

Define:

  • POV: CSP students need to translate a real backend requirement into a Boolean expression, because one incorrect condition can accept invalid data or reject valid data.
  • Learning Goal: Students will write and evaluate relational and logical expressions, combine conditions with and, or, and not, and use the final Boolean result in backend decisions.

Ideate:

  • HMW Question: How might we turn an English backend rule into small Boolean checks that are easy to verify?
  • HMW Question: How might we test a Boolean rule with valid, invalid, and boundary cases before trusting it?
  • Activity: Trace short expressions, test SFI automotive records, then build a reusable backend validator.

Prototype & Test: Run each example, predict the result before execution, change at least one input, and verify that the Boolean expression still matches the written rule.


3. College Board Requirements

AP CSP Topic 3.5: Boolean Expressions focuses on writing and evaluating relational expressions. The course framework identifies Boolean values as true/false and uses relational operators to compare two variables, expressions, or values.

College Board Pseudocode

AP CSP questions use College Board pseudocode rather than Python syntax. Be able to recognize the same Boolean logic in both forms.

Relational and Logical Operators

College Board pseudocode Python
a = b a == b
a β‰  b a != b
a > b a > b
a < b a < b
a β‰₯ b a >= b
a ≀ b a <= b
NOT condition not condition
condition1 AND condition2 condition1 and condition2
condition1 OR condition2 condition1 or condition2

SFI Validation in College Board Pseudocode

Code Runner Challenge

Tech Talk 1 - Compare SFI Part Data

View IPYNB Source
hasProductName ← (productName β‰  "")
validCategory ← (category = "Auto Racing") OR (category = "Drag Racing")
hasSpecNumber ← (specNumber β‰  "")
hasEffectiveDate ← (effectiveDate β‰  "")
duplicateSpec ← (specNumber = "1.1") OR (specNumber = "2.1")

isValid ← hasProductName AND validCategory AND hasSpecNumber
           AND hasEffectiveDate AND NOT duplicateSpec

IF (isValid)
{
    DISPLAY("ACCEPT RECORD")
}
ELSE
{
    DISPLAY("REJECT RECORD")
}
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

Read It Like the Exam

  1. Evaluate each relational expression first.
  2. Apply NOT to the condition it belongs to.
  3. Combine conditions with AND/OR.
  4. Determine whether the IF condition is true or false.
  5. Be careful: College Board comparison uses =, while Python comparison uses ==.

Pseudocode Check

For one of your own test records, predict the pseudocode output before running the Python validator. Then verify that both representations make the same decision.


4. Lesson Plan

Learning Objective: Write and evaluate Boolean expressions that compare values and combine multiple backend requirements.

Success Criteria: You can predict whether an expression is True or False, explain why, choose the correct relational/logical operator, and test a compound rule with more than one input.

Lesson Theme β€” SFI Safety Tech Inspector

Theme: You are building validation logic for an SFI automotive safety-spec backend.

Every example uses the same story instead of switching contexts:

  • Product: an automotive safety component such as a flywheel or clutch assembly.
  • Category: a racing category such as Auto Racing or Drag Racing.
  • Spec number: the identifier that must be present and unique.
  • Effective date: required metadata for an approved record.
  • Backend decision: accept, reject, return, or filter a record.

The theme matters because Boolean expressions become easier to reason about when every condition answers a real backend question:

β€œDoes this record satisfy every rule required before it is accepted?”

As the lesson progresses, students move from checking one field to validating an entire candidate record.

Teaching rhythm

Pause for each Popcorn Hack during the lesson: give students about two minutes to predict, edit and run the nearby code, then ask a partner to explain the result before continuing. Students copy their work and visible output into their own notebook after the live check. Save the independent Homework Hack for after class.

Tech Talk (short segments between checks)

A Boolean expression is a question whose result is only True or False.

Python comparison operators:

Python Meaning SFI example
== equal to spec_number == "1.1"
!= not equal to category != "Street Car"
> greater than part_count > 0
< less than part_count < 100
>= greater than or equal to part_count >= 1
<= less than or equal to part_count <= 100

Logical operators combine Boolean values:

Operator Meaning Example
and both conditions must be true name exists and spec exists
or at least one condition is true Auto Racing or Drag Racing
not reverses a Boolean value not a duplicate

Remember: = assigns a value in Python, while == compares values.


5. Code Examples

A. Simple: Comparisons Create Booleans

Code Runner Challenge

Popcorn Hack 1 - Check SFI Part Fields

View IPYNB Source
# CODE_RUNNER: Tech Talk 1 - Compare SFI Part Data

spec_number = "1.1"
category = "Auto Racing"
part_count = 12

print("Spec is 1.1:", spec_number == "1.1")
print("Category is not Street Car:", category != "Street Car")
print("At least one part record exists:", part_count >= 1)
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

Popcorn Hack 1: Check One SFI Part Record

An SFI automotive record is complete when it has a product name, a racing category, a spec number, and an effective date.

For this challenge, Auto Racing and Drag Racing are valid racing categories. Your finished runner should report the Boolean state of each requirement for the record below.

In class (2 minutes): Predict the first output, complete the runner, run it, then change one input and compare with a partner. Save your code and output in your personal notebook.

Code Runner Challenge

Tech Talk 2 - Combine SFI Backend Checks

View IPYNB Source
# CODE_RUNNER: Popcorn Hack 1 - Check SFI Part Fields

part = {
    "product_name": "Replacement Flywheels and Clutch Assemblies",
    "category": "Auto Racing",
    "spec_number": "1.1",
    "effective_date": "Nov. 9, 2001"
}

valid_categories = ["Auto Racing", "Drag Racing"]

# Build and test your solution below.
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

B. Combine Conditions

Backend validation usually needs several checks at once.

Code Runner Challenge

Popcorn Hack 2 - Backend Create Rule

View IPYNB Source
# CODE_RUNNER: Tech Talk 2 - Combine SFI Backend Checks

has_product_name = True
has_spec_number = True
duplicate_spec = False

print("Required fields present:", has_product_name and has_spec_number)
print("At least one field present:", has_product_name or has_spec_number)
print("Spec is new:", not duplicate_spec)
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

Popcorn Hack 2: Backend Create Rule

The backend receives the same style of SFI part record. A new database record should only be created when all required fields are valid and its spec number is not already stored.

Build the final create decision and test it with at least one valid case and one rejected case.

In class (2 minutes): Decide what the first run should show, complete and run the code, then change one input to test the opposite case. Explain the result aloud and transfer both cases to your notebook.

Code Runner Challenge

Tech Talk 3 - SFI Record Validation

View IPYNB Source
# CODE_RUNNER: Popcorn Hack 2 - Backend Create Rule

part = {
    "product_name": "Replacement Flywheels and Clutch Assemblies",
    "category": "Auto Racing",
    "spec_number": "1.1",
    "effective_date": "Nov. 9, 2001"
}

valid_categories = ["Auto Racing", "Drag Racing"]
existing_spec_numbers = ["1.1", "2.1"]

# Build and test your solution below.
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

C. Compound Validation Rule

Build small Boolean checks first, then combine them into one readable result.

Code Runner Challenge

Tech Talk 4 - SFI Backend Decision

View IPYNB Source
# CODE_RUNNER: Tech Talk 3 - SFI Record Validation

has_product_name = True
has_spec_number = True
valid_category = True
duplicate_spec = False

basic_record_is_valid = (
    has_product_name
    and has_spec_number
    and valid_category
    and not duplicate_spec
)

print("Basic SFI record is valid:", basic_record_is_valid)
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

D. Use a Boolean to Control a Decision

An if statement can use the final Boolean result to decide whether the backend accepts, returns, or rejects a record.

Code Runner Challenge

Popcorn Hack 3 - SFI Search Filter

View IPYNB Source
# CODE_RUNNER: Tech Talk 4 - SFI Backend Decision

part_in_database = True
record_archived = False

can_return_record = part_in_database and not record_archived

if can_return_record:
    print("Return the SFI part record")
else:
    print("Do not return the SFI part record")
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

Popcorn Hack 3: SFI Search Filter

An SFI backend search can match a record through either its product name or its exact spec number. Search results should only include records from accepted racing categories.

Use the provided records and query to return only valid matches. Your logic should still work when the query or record data changes.

In class (3 minutes): Predict a match and a nonmatch, complete and run the code, then change the query or action. Share why the result changed; preserve your tested work in your notebook.

# CODE_RUNNER: Popcorn Hack 3 - SFI Search Filter

query = "1.2"

records = [
    {
        "product_name": "Replacement Flywheels and Clutch Assemblies",
        "category": "Auto Racing",
        "spec_number": "1.1"
    },
    {
        "product_name": "Multiple Disc Clutch Assemblies",
        "category": "Drag Racing",
        "spec_number": "1.2"
    },
    {
        "product_name": "Racing Flywheel Record",
        "category": "Auto Racing",
        "spec_number": "2.1"
    }
]

valid_categories = ["Auto Racing", "Drag Racing"]

# Build and test your solution below.

In-class MCQ Check

4 questions, one at a time. Answer each question, check it, then continue. At the end, copy the result line into your notebook and submission Notes.


6. Independent Homework & Submission

The three Popcorn Hacks above are live understanding checks. You are responsible for copying or preparing their code, predictions, and visible output in your personal notebook; the lesson page does not collect that work for you. Do the Homework Hack independently after the lesson.

Prepare your submission IPYNB

  1. In your portfolio, create a separate notebook under _notebooks/homework for this lesson. Keep the roughly four lesson notebooks expected for submission ready and individually identifiable; this lesson accounts for one notebook.
  2. Put this submission notebook frontmatter in a raw cell at the very top. It differs from the lesson page frontmatter above. Replace yourGithubID with your own ID:
---
layout: post
codemirror: true
title: 3.05 Boolean Expressions HW
categories: [Python]
lesson_language: Python
lesson_topic: Boolean-Expressions HW
lesson_part: interactive
lesson_type: lesson
permalink: /python/boolean-hw
author: yourGithubID
---
  1. Add your three in-class Popcorn Hacks with predictions and output, the MCQ result, then your independent Homework Hack and test output. Use headings to separate them. Run the notebook and publish your portfolio page.
  2. Submit the runnable Homework Hack Python code in the Code Submission form below. Put the published notebook link, your MCQ result, and brief test evidence in the Notes field. Do not paste a notebook file or Markdown fences into the code field.

Suggested Notes:

Lesson: CSP 3.05 Boolean Expressions
Notebook: <published URL>
MCQ 3.05: <paste result line>
Popcorn Hacks 1–3 completed during class and copied to notebook: yes
Homework tested: <cases or runs and observed output>

Keep the Homework Hack self-contained so the submitted code runs without the earlier lesson cells. The homework below is a written prompt and starter code to transfer into your notebook; work through it independently.

Homework Hack (independent): SFI Backend Validator

Build a reusable validator for candidate SFI automotive records.

A valid record has:

  • a non-empty product name,
  • an accepted racing category,
  • a non-empty spec number,
  • an effective date,
  • and a spec number that does not already exist in the backend.

The provided test data includes different cases. Your completed runner should clearly print whether each candidate record is accepted or rejected.

Copy this starter into your personal submission notebook after class. Complete it there, run multiple tests, and include the output. This is a reference block, not an in-page runner:

# Homework Hack - SFI Backend Validator

existing_spec_numbers = ["1.1", "2.1"]
valid_categories = ["Auto Racing", "Drag Racing"]

test_records = [
    {
        "product_name": "Multiple Disc Clutch Assemblies",
        "category": "Auto Racing",
        "spec_number": "1.2",
        "effective_date": "Feb. 9, 2006"
    },
    {
        "product_name": "Replacement Flywheels",
        "category": "Street Car",
        "spec_number": "3.1",
        "effective_date": "Jan. 1, 2026"
    },
    {
        "product_name": "Existing Flywheel Record",
        "category": "Drag Racing",
        "spec_number": "1.1",
        "effective_date": "Jan. 1, 2026"
    }
]

# Build and test your validator below.

Grading Plan (1 Point Total)

Part Points What earns the points
Popcorn Hack 1 0.10 Correct field/category Boolean checks with visible output.
Popcorn Hack 2 0.15 Correct create decision using required fields and duplicate handling.
Popcorn Hack 3 0.20 Search logic correctly combines query matching and accepted-category filtering.
MCQ 0.15 All questions attempted and result line included; full credit for 4/4.
Homework Validator 0.40 Reusable validator correctly accepts/rejects the supplied cases and explains the Boolean logic.
Total 1.0 Β 

Quick Validation Checklist

  • Each in-class Popcorn Hack was tested and transferred to the personal notebook with visible output.
  • At least one valid and one invalid case were tested.
  • Duplicate-spec behavior is tested.
  • and, or, and not match the written requirement.
  • MCQ result line and the published personal notebook link are ready for the Notes field.
  • Section 3 College Board pseudocode has been reviewed and compared with the Python solution.
  • Publish your notebook with submission frontmatter; submit the final Homework Hack Python code through the Code Submission form below.

7. Lesson Revisions

  • Kept one consistent SFI automotive/backend context across the lesson.
  • Organized examples from simple comparisons to compound validation and backend decisions.
  • Added a reference guide and AP CSP alignment so students can connect Python syntax to exam concepts.
  • Added an interactive MCQ checkpoint before the final homework validator.
  • Kept student-facing runners as starter scaffolds rather than completed homework solutions.
  • Placed College Board pseudocode alongside the AP CSP requirements in Section 3.
  • Placed the SFI lesson theme within the lesson plan.
  • Switched the assignment frontmatter to autograded code submission and added assignment creator UIDs.

Revision Made: Aligned the nine sections with the 1.02 lesson format and aligned submission metadata/instructions with code-based autograding.

  • Embedded the three live Popcorn Hacks beside their teaching examples; made homework a noninteractive notebook starter and documented personal notebook submission frontmatter.

8. Feedback Evidence

Feedback Received: The lesson model should include the seven core stages, an optional theme stage, required College Board pseudocode, and autograder frontmatter.


9. References

College Board. AP Computer Science Principles Course and Exam Description, Topic 3.5 Boolean Expressions and the AP CSP Exam Reference Sheet.

Python Software Foundation. Python Documentation: Boolean Operations and Comparisons.

Submit Assignment

Your code will be saved as a Gist and reviewed automatically. You must be logged in to submit.

Need to update a submission later? Open the submissions dashboard.