def sqrt(n):
    '''return the square root of n in an exact representation'''
    if isinstance(n, Rational):
        n = Constructible(n)
    elif not isinstance(n, Constructible):
        raise ValueError('the square root is not implemented for the type %s' % type(n))

    r = n._try_sqrt()  # pylint: disable=protected-access
    if r is not None:
        return r
    return Constructible(Constructible.lift_rational_field(0, n.field),
                         Constructible.lift_rational_field(1, n.field),
                         (n, n.field))
def sqrt ( n ) : if isinstance ( n , Rational ) : n = Constructible ( n ) elif not isinstance ( n , Constructible ) : raise ValueError ( 'the square root is not implemented for the type %s' % type ( n ) ) r = n . _try_sqrt ( ) if r is not None : return r return Constructible ( Constructible . lift_rational_field ( 0 , n . field ) , Constructible . lift_rational_field ( 1 , n . field ) , ( n , n . field ) )
return the square root of n in an exact representation