Operators

Lesson 3 of 20

Arithmetic, comparison and logic — watch operators combine values and learn which one computes first.

The big picture

Doing things with values

Operators are the verbs of Python — they add, compare and combine the values your program holds.

Arithmetic

+ - * / do the math you know; / always returns a float, even 10 / 2.

Comparisons

> < == != compare two values and answer with True or False.

Logic

and, or and not combine booleans into smarter questions.

Precedence

* binds tighter than +; parentheses ( ) let you decide the order yourself.