---
title: "Boolean Expressions and Comparison Operators"
description: "Expressions that come out true or false: comparisons between values, and the way and, or and not combine them."
canonical: https://lightmysky.com/learn/computing/boolean-expressions-and-comparison-operators-mt_0aIh-DPCZ4
source: https://lightmysky.com/learn/computing/boolean-expressions-and-comparison-operators-mt_0aIh-DPCZ4.md
retrieved: 2026-09-12
---

> **Agent view.** This is the Markdown twin of the page, for tools and assistants.
> When to use this site, and the call that answers each job: https://lightmysky.com/agent-instructions.md
> API description (OpenAPI 3.1): https://lightmysky.com/openapi.json · Authentication: https://lightmysky.com/auth.md
> Pricing: https://lightmysky.com/pricing.md · Catalog: https://lightmysky.com/llms.txt · Full catalog: https://lightmysky.com/llms-full.txt
> Every machine-readable file on this domain: https://lightmysky.com/.well-known/ai-catalog.json
> Ask for Markdown with `Accept: text/markdown`, a `.md` address, or `?mode=agent`.

# Boolean Expressions and Comparison Operators

Expressions that come out true or false: comparisons between values, and the way and, or and not combine them.

Subject: Computing · Area: Programming · Ages 14 to 15
Page: https://lightmysky.com/learn/computing/boolean-expressions-and-comparison-operators-mt_0aIh-DPCZ4

## Ready when they can

- Write a condition that is true only inside a range of values
- Predict the value of a condition that joins two comparisons with and or or
- Rewrite a condition using not without changing what it means

## Lesson: True, false, and in between

Programs ask questions that answer true or false, like score > 10 or temperature < 32. A snow jacket warning runs when temperature < 32 is true, and stays quiet when it is false. Every decision in code rests on one of these answers.

**Example.** To catch numbers from 5 to 9 you write n >= 5 and n <= 9. The word and needs both sides true, while or needs only one side true. With n at 7 the whole test is true, and with n at 12 the first half fails so the test is false.

The word not flips an answer, and two nots cancel back out. So not age < 13 means exactly the same as age >= 13. Swapping an operator plus not keeps the meaning while making the code easier to read.

**Tip.** Read each condition aloud with real values plugged in. Also remember that one equals sign stores a value while two compare values, so mixing them up breaks your logic quietly.

**Recap.** Comparisons answer true or false, and and, or and not join them into bigger tests.

## Practice

8 questions on this page, each with its working shown.

## Needs first

- [Arithmetic in Code: Integer Division and Remainder](https://lightmysky.com/learn/computing/arithmetic-in-code-integer-division-and-remainder-mt_ZPnPrLGPmT)
- [Conditions That Combine: And, Or and Not](https://lightmysky.com/learn/computing/conditions-that-combine-and-or-and-not-mt_ZYdtXQZy5r)

## Opens up

- [Boolean Algebra and Simplifying Logic Expressions](https://lightmysky.com/learn/computing/boolean-algebra-and-simplifying-logic-expressions-mt_9MrE1N63D5)
- [SQL: Selecting, Filtering and Ordering Rows](https://lightmysky.com/learn/computing/sql-selecting-filtering-and-ordering-rows-mt_lDVVG2AKzs)
- [Logic Gates and Truth Tables](https://lightmysky.com/learn/computing/logic-gates-and-truth-tables-mt_o2N0-q3A4Q)
- [Selection with if, elif and else](https://lightmysky.com/learn/computing/selection-with-if-elif-and-else-mt_zylJ-p9g1g)
