Most of these are rarely used, but it’s good to know they exist and that they can be overridden.

  • __add__: The addition method. It is called when the + operator is used on an object.
  • __sub__: The subtraction method. It is called when the - operator is used on an object.
  • __mul__: The multiplication method. It is called when the * operator is used on an object.
  • __truediv__: The true division method. It is called when the / operator is used on an object.
  • __floordiv__: The floor division method. It is called when the // operator is used on an object.
  • __mod__: The modulo method. It is called when the % operator is used on an object.
  • __pow__: The power method. It is called when the ** operator is used on an object.