We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Operator Overload Review

As we discussed in the last assignment, operator overloading is the practice of defining custom behavior for standard Python operators. Here's a list of how the operators translate into method names.

Operation Operator Method
Addition + __add__
Subtraction - __sub__
Multiplication * __mul__
Power ** __pow__
Division / __truediv__
Floor Division // __floordiv__
Remainder (modulo) % __mod__
Bitwise Left Shift << __lshift__
Bitwise Right Shift >> __rshift__
Bitwise AND & __and__
Bitwise OR | __or__
Bitwise XOR ^ __xor__
Bitwise NOT ~ __invert__