class Square:
def init(self, side):
self.side = side
def eq(self, other):
return self.side == other.side
def ne(self, other):
return self.side != other.side
def lt(self, other):
return self.side < other.side
def le(self, other):
return self.side <= other.side
def gt(self, other):
return self.side > other.side
def ge(self, other):
return self.side >= other.side
sq1 = Square(10)
sq2 = Square(11)
print(sq1 != sq2)
print(sq1 < sq2)
print(sq1 <= sq2)
print(sq1 > sq2)
print(sq1 >= sq2)
+: object.add(self, other)
-: object.sub(self, other)
: object.mul(self, other)
/: object.div(self, other)
%: object.mod(self, other)
*: object.pow(self, other)
&: object.and(self, other)
^: object.xor(self, other)
|: object.or(self, other)
+=: object.iadd(self, other) ("i" for in place)
-=: object.isub(self, other)
=: object.imul(self, other)
/=: object.idiv(self, other)
%=: object.imod(self, other)
*=: object.ipow(self, other)
-: object.neg(self)
+: object.pos(self)
abs(): object.abs(self)
int(): object.int(self)
float(): object.float(self)
Top comments (0)