Школа179: Rational

https://ejudge.179.ru/wiki     Редакция: 0 (28.03.2024 13:33)

Rational

import math

class Rational:
    def __init__(self, p, q):
        self.p = p
        self.q = q
        self.normalize()

    def normalize(self):
        gcd = math.gcd(self.p, self.q)
        # ...

    def __add__(self, other):
        pass
        # return Rational(..., ...)

    def __sub__(self, other):
        pass
        # return Rational(..., ...)

    def __mul__(self, other):
        pass
        # return Rational(..., ...)

    def __truediv__(self, other):
        pass
        # return Rational(..., ...)

    def __repr__(self):
        pass
        # return f"..."