Overloading Equality Operator
Mon 10 August 2026
class Point:
def __init__(self, x):
self.x = x
def __eq__(self, other):
return self.x == other.x
p1 = Point(5)
p2 = Point(5)
print(p1 == p2) # True
True
Score: 10
Category: chapter5_operator_overloading