Comparison
A comparison is a language operation that evaluates a relationship, such as equality or ordering, between values and produces a result representing that relationship.
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 →
JavaScript in Depth
Language semantics and operators for testing relational ordering or equality between values.
- How it is used
- Diagnoses surprising equality, ordering, sorting, and string-matching results in JavaScript.
- How deep it goes
- Works through loose-equality conversions, contrasts relational coercion, and explains UTF-16 string comparison and normalization.
- Examples
- Uses `true == '1'`, mixed-type ordering, default array sorting, and visually identical usernames with different Unicode sequences.
- What you can do after
- Diagnose/debug with it by identifying unintended coercion, string sorting, and Unicode-equivalence failures before choosing a comparison strategy.
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.
Also covered in
- Python Workout: 50 ten-minute exercises
- Data-Oriented Programming: Reduce software complexity
- Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools
- Kotlin in Action, 2E
- Learn SQL in a Month of Lunches
- Learn C++ by Example
- Django in Action
- Practical Automation with PowerShell: Effective scripting from the console to the cloud
- Elixir in Action, Third Edition
- The Quick Python Book, Fourth Edition
- Learn Go with Pocket-Sized Projects
- Data-Oriented Programming in JavaIn early access (MEAP)
What to know first
- stringA string is a programming-language value representing textual data as an ordered sequence of characters or encoded units.
- booleanA Boolean is a logical value or data type representing truth or falsity, conventionally with the two values true and false.
- objectAn object is a distinct entity represented or manipulated within a computational system, typically as a value, data structure, resource, or instance of a type.
- regular expressionA regular expression is a formal pattern notation that describes sets of strings and specifies how text can be matched, searched, or transformed.
Related concepts
- arraycontrasts with · An array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
- 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 value or data type representing truth or falsity, conventionally with the two values 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.
Questions about comparison
What is comparison?
A comparison is a language operation that evaluates a relationship, such as equality or ordering, between values and produces a result representing that relationship.
Which Manning books explain comparison?
A Pythonic Adventure: From Python basics to a working web app, Learn AI-Assisted Python Programming, Second Edition, JavaScript in Depth, Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS, Modern C, Third Edition, The Well-Grounded Rubyist, Fourth Edition, Modern C, Python Workout, Second Edition and 1 more.
What should I know before learning comparison?
Manning books that teach comparison usually introduce string, boolean, object and regular expression first.
What is the difference between comparison and array?
A comparison is a language operation that evaluates a relationship, such as equality or ordering, between values and produces a result representing that relationship. An array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
What kinds of comparison are there?
Kinds of comparison include string comparison and greater-than-or-equal operator.
What is comparison a kind of?
Comparison is a kind of operator. An operator is a symbol, keyword, or language construct that specifies an operation on one or more operands.
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.








