def square(x): """checks if x is a square number""" sq = root(x, 2) if sq.is_integer(): return True else: return False
def cube(x): """ Checks if X is a cube number :param x: :return: >>> cube(2) False >>> cube(9) False >>> cube(8) True """ c = root(x, 3) if float.is_integer(c): return True else: return False
def __rpow__(self, other, modulo=None): from amath.Computation.power import root return pow(root(other, self.denominator), self.numerator)