Operators & Expressions
Python · Beginner
Definition
Operators perform arithmetic (+ − * / // % **), comparison, logical (and/or/not) and membership (in).
Every calculation and condition uses operators.
Diagram
Flowchart
Example: Common operators
print(7 / 2, 7 // 2, 7 % 2, 2 ** 3, 3 in [1, 2, 3])Output: 3.5 3 1 8 True
Key points
- // floors toward −∞
- is checks identity, == checks equality
Interview questions
is vs ==?
== compares values; is compares whether two names point to the same object.