Write a python function that finds square roots of a given number, if the square root is an integer, else returns the message "Error - the square root is not an integer"


Topic: Write a python function that finds square roots of a given number, if the square root is an integer, else returns the message "Error - the square root is not an integer"

Solution

def find_integer_square_roots(num):
    found = False
    for k in range(1, (num//2)+1):
        if ((k**2)==num):
            found = True
            break
    if not found:
        return "Error - the square root is not an integer"
    return -k, k



List all Python Programs