Overloading Division Operator

Mon 10 August 2026
class Calculator:
    def __init__(self, value):
        self.value = value

    def __truediv__(self, other):
        return self.value / other.value

c1 = Calculator(100)
c2 = Calculator(4)

print(c1 / c2)  # Output: 25.0
25.0


Score: 10

Category: chapter5_operator_overloading