🐍 Python
Beginner
What are Python's comparison and logical operators?
Answer
Python comparison operators return booleans: == (equal), != (not equal), <, >, <=, >=. Python supports chained comparisons: 0 < x < 10 (equivalent to 0 < x and x < 10). Logical operators: and, or, not. Python uses short-circuit evaluation: a and b returns a if a is falsy, otherwise b. a or b returns a if truthy, otherwise b. This enables Pythonic patterns: name = input_name or "default". Identity operators: is, is not. Membership operators: in, not in — check membership in sequences, dicts (by key), and sets. Bitwise operators: &, |, ^, ~, <<, >>.