Comparison
A comparison is a language operation that tests a relationship between values or expressions, such as equality or ordering, and produces a result.
A Pythonic Adventure: From Python basics to a working web app
A comparison operator evaluates a relationship between values and produces a Boolean result.
- How it is used
- Uses equality comparisons to validate menu input before indexing a list.
- How deep it goes
- Explains ==, separate comparisons, or, invalid inputs, and looped validation, but does not develop comparison operators beyond equality.
- Examples
- Uses a drinks menu, numbered choices, invalid entries, exit commands, and a final menu function.
- What you can do after
- Apply it via Python to validate interactive menu choices and route valid or invalid input.
Read how A Pythonic Adventure: From Python basics to a working web app explains comparison →
Learn AI-Assisted Python Programming, Second Edition
- How it is used
- Uses comparisons to make conditional decisions and select or count values meeting specified criteria.
- How deep it goes
- Defines Boolean comparisons and demonstrates them in conditionals, but does not develop identity or membership comparisons.
- Examples
- Demonstrates larger-value selection, age-based prompts, longest-word tests, and inclusive versus exclusive numeric ranges.
- What you can do after
- Diagnose boundary bugs and apply comparisons in Python conditionals and doctest-backed functions.
Read how Learn AI-Assisted Python Programming, Second Edition explains comparison →
Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS
A comparison is an expression that evaluates a relationship between values and produces a Boolean result.
- How it is used
- Uses Boolean tests to filter objects retrieved into the PowerShell pipeline.
- How deep it goes
- Explains operator categories, Boolean logic, placeholders, properties, and pipeline behavior through process-filtering examples.
- Examples
- Demonstrates numeric, date, string, process-response, and process-memory comparisons.
- What you can do after
- Apply comparisons through Where-Object to retain pipeline objects matching numeric, property-based, or combined conditions.
Modern C, Third Edition
A comparison operator is a C operator that evaluates a relational condition between two operands and produces a Boolean result.
- How it is used
- Uses relational expressions in control flow, arithmetic, and array indexing.
- How deep it goes
- Defines six operators and their 0-or-1 results, with worked arithmetic examples but no deeper evaluation mechanics.
- Examples
- Uses relational arithmetic with a and b and classifies array elements by comparing them with 1.0.
- What you can do after
- Apply comparisons in conditions, arithmetic expressions, and Boolean-indexed arrays.
The Well-Grounded Rubyist, Fourth Edition
A comparison operator is Ruby syntax that compares two values or objects for ordering or equality.
- How it is used
- Explains how Ruby objects define equality and ordering, then use Comparable to supply a full operator family.
- How deep it goes
- Shows a Bid implementation, the spaceship method’s return convention, and a shorter delegation to numeric estimates.
- Examples
- Uses bids ordered by estimates and notes that strings compare for equality and order.
- What you can do after
- Build from scratch a class whose objects support Ruby comparison operators by defining `<=>` and including Comparable.
Read how The Well-Grounded Rubyist, Fourth Edition explains comparison →
Modern C
A comparison operator is a C operator that compares values and produces a Boolean result represented by zero or one.
- How it is used
- Deploys comparisons in expressions, control statements, arithmetic, and array indexing.
- How deep it goes
- Explains six comparison operators and their 0-or-1 results through worked expressions, without developing logical evaluation.
- Examples
- Uses equality-counting expressions and an array-indexing loop that classifies values relative to 1.0.
- What you can do after
- Apply comparison results as Boolean values in conditions, arithmetic expressions, and array subscripts.
Python Workout, Second Edition
A comparison operator is a Python operator that evaluates a relationship between two values and produces a Boolean result.
- How it is used
- Drives a number-guessing loop by testing a user's guess against a randomly chosen integer.
- How deep it goes
- Explains ==, !=, <, and > through a worked program and type restrictions, without surveying additional comparison behavior.
- Examples
- Uses a random-integer guessing exercise with converted user input and equality, less-than, and greater-than tests.
- What you can do after
- Apply it via Python comparisons that control a loop and distinguish numeric guesses from a randomly selected answer.
Read how Python Workout, Second Edition explains comparison →
Math for Web Design
A comparison operator is an operator that specifies the relationship to test between two values.
- How it is used
- Deploys comparisons to control responsive layouts, validation, sizing, positioning, and animation decisions.
- How deep it goes
- Explains operator meanings, CSS shorthand, JavaScript coercion, strict equality, and numeric conversion through practical examples.
- Examples
- Uses responsive breakpoints, clamped font sizes, input selectors, password length checks, and string-to-number comparisons.
- What you can do after
- Apply comparisons via CSS and JavaScript to make predictable layout, validation, and animation decisions.
Related concepts
- arraycontrasts with · An array is an indexed, ordered collection of elements arranged in one or more dimensions, with elements accessed by position.
- membership operatoralternative to · A membership operator is a language construct that tests whether a specified value or property is present in a supported collection, range, or object.
- operatorkind of · An operator is a symbol, keyword, or language construct that specifies an operation on one or more operands.
- booleanproduces · A Boolean is a logical type or value representing truth or falsity, conventionally with two states: true and false.
- greater-than-or-equal operatorincludes · The greater-than-or-equal operator compares values and indicates whether its first operand is at least as large as its second operand or a specified lower bound.
- wildcarduses · A wildcard is a pattern symbol or expression that matches unspecified or variable characters, values, names, types, or path segments.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.







