liveBook · Manning

Comparison

As explained in A Pythonic Adventure: From Python basics to a working web app

A comparison operator evaluates a relationship between values and produces a Boolean result.

A comparison checks whether values relate in a particular way and produces a Boolean result. In Python, == checks equality, such as choice == '1'. section 4.0

Checking a menu choice

To accept three menu choices, compare the input separately and join the comparisons with or: if choice == '1' or choice == '2' or choice == '3':. Valid input selects an item; other input receives an error message. section 4.0

How A Pythonic Adventure: From Python basics to a working web app covers it

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 it assumes
Assumes basic Python input, functions, lists, and if-else, while teaching equality comparison through a menu problem.
What you can do after
Apply it via Python to validate interactive menu choices and route valid or invalid input.
How it connects
Connects comparisons with if-else, logical or, input validation, list indexing, and while loops.

Also explained in

Compare how 8 books explain comparison →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of A Pythonic Adventure: From Python basics to a working web app. The section links point to the parts of the book it draws on.