Our code lets us input a number, but then does not let us find the square root of it. Is the code only allowing us to square root perfect squares, or is it something else. Here is the code:
elif a == "Square" or a == "Square please":
print("Please enter a number:")
num1 = int(input())
print("Your answer is:")
answer = sqrt(num1)
print(answer)
Here is the error: What number would you like squared?: 25
It shows up blank and does not answer.
After adding the math import sqrt right after the if statement, it shows up with this error.
Traceback (most recent call last):
File "python", line 236, in <module>
File "python", line 103, in personality
UnboundLocalError: local variable 'sqrt' referenced before assignment
Here is everything I can show you without compromising the confidentiality of the project I am undertaking.
elif a == "Square" or a == "Square please":
from math import sqrt
print("Please enter a number:")
num1 = int(input())
print("Your answer is:")
answer = sqrt(num1)
print(answer)