Tutorials

Python 3 Tutorial

All Tutorials Learning Tools Login

Python 3 Tutorial · Chapter 9 of 22

Python Operators

Compute and compare values.

Arithmetic operators: + - * / // % **. Comparison operators: == != < > <= >=.

Use == for comparison. A single = assigns a value.

Operators sample Try it Yourself »
a = 10
b = 3
print("Sum =", a + b)
print("Remainder =", a % b)

Classroom Tips

  • / always gives a float. Use // for integer division.
  • Parentheses make order of operations clearer.