Mathematical Operations

Methods for Math Operations

Method Result
__add__(self, other) self+otherself + other
__sub__(self, other) selfotherself - other
__mul__(self, other) selfotherself * other
__truediv__(self, other) self/otherself / other
__floordiv__(self, other) self//otherself // other
__mod__(self, other) selfself % other
__divmod__(self, other) divmod(self,other)divmod(self,other)
__pow__(self, other) selfotherself ** other
__lshift__(self, other) self<<otherself << other
__rshift__(self, other) self>>otherself >> other
__and__(self, other) self&otherself \And other
__or__(self, other) selfotherself \vert other
__xor__(self, other) self ^ other
__iadd__(self, other) self+=otherself += other
__isub__(self, other) self=otherself -= other
__imul__(self, other) self=otherself *= other
__itruediv__(self, other) self/=otherself /= other
__ifloordiv__(self, other) self//=otherself //= other
__imod__(self, other) self %= other
__ipow__(self, other) self=otherself **= other
__iand__(self, other) self&=otherself \And = other
__ior__(self, other) self=otherself \vert = other
__ixor__(self, other) self ^= other
__ilshift__(self, other) self<<=otherself <<= other
__irshift__(self, other) self>>=otherself >>= other
__neg__(self) self-self
__pos__(self) +self+self
__abs__(self) abs(self)abs(self)
__invert__(self)  self~self
__int__(self) int(self)int(self)
__float__(self) float(self)float(self)
__complex__(self) complex(self)complex(self)

References

Previous
Next

Iteration

Callable Interface